[前][次][番号順一覧][スレッド一覧]

ruby-changes:50811

From: usa <ko1@a...>
Date: Wed, 28 Mar 2018 23:36:27 +0900 (JST)
Subject: [ruby-changes:50811] usa:r63018 (ruby_2_2): merge revision(s) 62991, 63000:

usa	2018-03-28 23:36:23 +0900 (Wed, 28 Mar 2018)

  New Revision: 63018

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=63018

  Log:
    merge revision(s) 62991,63000:
    
    unixsocket.c: check NUL bytes
    
    * ext/socket/unixsocket.c (rsock_init_unixsock): check NUL bytes.
      https://hackerone.com/reports/302997
    
    unixsocket.c: abstract namespace
    
    * ext/socket/unixsocket.c (unixsock_path_value): fix r62991 for
      Linux abstract namespace.

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/ChangeLog
    branches/ruby_2_2/ext/socket/unixsocket.c
    branches/ruby_2_2/test/socket/test_unix.rb
    branches/ruby_2_2/version.h
Index: ruby_2_2/test/socket/test_unix.rb
===================================================================
--- ruby_2_2/test/socket/test_unix.rb	(revision 63017)
+++ ruby_2_2/test/socket/test_unix.rb	(revision 63018)
@@ -263,6 +263,16 @@ class TestSocket_UNIXSocket < Test::Unit https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/socket/test_unix.rb#L263
     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|
Index: ruby_2_2/ChangeLog
===================================================================
--- ruby_2_2/ChangeLog	(revision 63017)
+++ ruby_2_2/ChangeLog	(revision 63018)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ChangeLog#L1
+Wed Mar 28 23:35:28 2018  Nobuyoshi Nakada  <nobu@r...>
+
+	unixsocket.c: check NUL bytes
+
+	* ext/socket/unixsocket.c (rsock_init_unixsock): check NUL bytes.
+	  https://hackerone.com/reports/302997
+
+	unixsocket.c: abstract namespace
+
+	* ext/socket/unixsocket.c (unixsock_path_value): fix r62991 for
+	  Linux abstract namespace.
+
 Wed Mar 28 23:30:32 2018  SHIBATA Hiroshi  <hsbt@r...>
 
 	Ignore file separator from tmpfile/tmpdir name.
Index: ruby_2_2/ext/socket/unixsocket.c
===================================================================
--- ruby_2_2/ext/socket/unixsocket.c	(revision 63017)
+++ ruby_2_2/ext/socket/unixsocket.c	(revision 63018)
@@ -25,6 +25,28 @@ unixsock_connect_internal(VALUE a) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/socket/unixsocket.c#L25
 			        arg->sockaddrlen, 0);
 }
 
+static VALUE
+unixsock_path_value(VALUE path)
+{
+#ifdef __linux__
+#define TO_STR_FOR_LINUX_ABSTRACT_NAMESPACE 0
+
+    VALUE name = path;
+#if TO_STR_FOR_LINUX_ABSTRACT_NAMESPACE
+    const int isstr = !NIL_P(name = rb_check_string_type(name));
+#else
+    const int isstr = RB_TYPE_P(name, T_STRING);
+#endif
+    if (isstr) {
+        if (RSTRING_LEN(name) == 0 || RSTRING_PTR(name)[0] == '\0') {
+            rb_check_safe_obj(name);
+            return name;             /* ignore encoding */
+        }
+    }
+#endif
+    return rb_get_path(path);
+}
+
 VALUE
 rsock_init_unixsock(VALUE sock, VALUE path, int server)
 {
@@ -33,7 +55,7 @@ rsock_init_unixsock(VALUE sock, VALUE pa https://github.com/ruby/ruby/blob/trunk/ruby_2_2/ext/socket/unixsocket.c#L55
     int fd, status;
     rb_io_t *fptr;
 
-    SafeStringValue(path);
+    path = unixsock_path_value(path);
 
     INIT_SOCKADDR_UN(&sockaddr, sizeof(struct sockaddr_un));
     if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) {
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 63017)
+++ ruby_2_2/version.h	(revision 63018)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.10"
 #define RUBY_RELEASE_DATE "2018-03-28"
-#define RUBY_PATCHLEVEL 484
+#define RUBY_PATCHLEVEL 485
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2
===================================================================
--- ruby_2_2	(revision 63017)
+++ ruby_2_2	(revision 63018)

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r62991,63000

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]