mirror of
https://github.com/ruby/ruby.git
synced 2026-01-26 12:14:51 +00:00
[Bug #21705] Fix segfaults on Windows
It should check the type of the argument and coercion before converting the encoding.
This commit is contained in:
parent
a7f948c32c
commit
beb85e7eee
Notes:
git
2025-11-23 05:26:55 +00:00
@ -42,11 +42,12 @@ unixsock_path_value(VALUE path)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
path = rb_get_path(path);
|
||||
#ifdef _WIN32
|
||||
/* UNIXSocket requires UTF-8 per spec. */
|
||||
path = rb_str_export_to_enc(path, rb_utf8_encoding());
|
||||
#endif
|
||||
return rb_get_path(path);
|
||||
return path;
|
||||
}
|
||||
|
||||
VALUE
|
||||
|
||||
@ -293,14 +293,18 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase
|
||||
File.unlink path if path && File.socket?(path)
|
||||
end
|
||||
|
||||
def test_open_nul_byte
|
||||
tmpfile = Tempfile.new("s")
|
||||
path = tmpfile.path
|
||||
tmpfile.close(true)
|
||||
assert_raise(ArgumentError) {UNIXServer.open(path+"\0")}
|
||||
assert_raise(ArgumentError) {UNIXSocket.open(path+"\0")}
|
||||
ensure
|
||||
File.unlink path if path && File.socket?(path)
|
||||
def test_open_argument
|
||||
assert_raise(TypeError) {UNIXServer.new(nil)}
|
||||
assert_raise(TypeError) {UNIXServer.new(1)}
|
||||
Tempfile.create("s") do |s|
|
||||
path = s.path
|
||||
s.close
|
||||
File.unlink(path)
|
||||
assert_raise(ArgumentError) {UNIXServer.open(path+"\0")}
|
||||
assert_raise(ArgumentError) {UNIXSocket.open(path+"\0")}
|
||||
arg = Struct.new(:to_path).new(path)
|
||||
assert_equal(path, UNIXServer.open(arg) { |server| server.path })
|
||||
end
|
||||
end
|
||||
|
||||
def test_addr
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user