summaryrefslogtreecommitdiff
path: root/test/socket/test_unix.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 10:08:57 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-03-28 10:08:57 +0000
commit8794dec6a5f11adc5cdd19a5ee91ea6b0816763f (patch)
tree4643691b50cb123319a0826d0118e9bd1ad5f560 /test/socket/test_unix.rb
parent10b96900b90914b0cc1dba36f9736c038db2859d (diff)
unixsocket.c: check NUL bytes
* ext/socket/unixsocket.c (rsock_init_unixsock): check NUL bytes. https://hackerone.com/reports/302997 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/socket/test_unix.rb')
-rw-r--r--test/socket/test_unix.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb
index 36f48c35ed..6efb1d60ee 100644
--- a/test/socket/test_unix.rb
+++ b/test/socket/test_unix.rb
@@ -284,6 +284,16 @@ 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)
+ end
+
def test_addr
bound_unix_socket(UNIXServer) {|serv, path|
UNIXSocket.open(path) {|c|