[ruby/openssl] ssl: fix SSLSocket#syswrite with String-convertible objects
Correctly pass the new object assigned by StringValue() to ossl_ssl_write_internal_safe(). This is a follow-up to commit https://github.com/ruby/openssl/commit/0d8c17aa855d (Reduce OpenSSL::Buffering#do_write overhead, 2024-12-21). https://github.com/ruby/openssl/commit/3ff096196a
This commit is contained in:
parent
bbf873521a
commit
0a8a641d0a
@ -2080,14 +2080,13 @@ ossl_ssl_write_internal_safe(VALUE _args)
|
|||||||
static VALUE
|
static VALUE
|
||||||
ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
|
ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
|
||||||
{
|
{
|
||||||
VALUE args[3] = {self, str, opts};
|
StringValue(str);
|
||||||
int state;
|
|
||||||
str = StringValue(str);
|
|
||||||
|
|
||||||
int frozen = RB_OBJ_FROZEN(str);
|
int frozen = RB_OBJ_FROZEN(str);
|
||||||
if (!frozen) {
|
if (!frozen) {
|
||||||
str = rb_str_locktmp(str);
|
rb_str_locktmp(str);
|
||||||
}
|
}
|
||||||
|
int state;
|
||||||
|
VALUE args[3] = {self, str, opts};
|
||||||
VALUE result = rb_protect(ossl_ssl_write_internal_safe, (VALUE)args, &state);
|
VALUE result = rb_protect(ossl_ssl_write_internal_safe, (VALUE)args, &state);
|
||||||
if (!frozen) {
|
if (!frozen) {
|
||||||
rb_str_unlocktmp(str);
|
rb_str_unlocktmp(str);
|
||||||
|
@ -270,6 +270,11 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase
|
|||||||
ssl.syswrite(str)
|
ssl.syswrite(str)
|
||||||
assert_same buf, ssl.sysread(str.size, buf)
|
assert_same buf, ssl.sysread(str.size, buf)
|
||||||
assert_equal(str, buf)
|
assert_equal(str, buf)
|
||||||
|
|
||||||
|
obj = Object.new
|
||||||
|
obj.define_singleton_method(:to_str) { str }
|
||||||
|
ssl.syswrite(obj)
|
||||||
|
assert_equal(str, ssl.sysread(str.bytesize))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user