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

ruby-changes:9996

From: yugui <ko1@a...>
Date: Fri, 16 Jan 2009 00:35:46 +0900 (JST)
Subject: [ruby-changes:9996] Ruby:r21537 (ruby_1_9_1): merges r21469 from trunk into ruby_1_9_1.

yugui	2009-01-16 00:35:25 +0900 (Fri, 16 Jan 2009)

  New Revision: 21537

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21537

  Log:
    merges r21469 from trunk into ruby_1_9_1.
    * ext/socket/socket.c (sock_s_unpack_sockaddr_in): check too short
      sockaddr.
      (sock_s_unpack_sockaddr_un): ditto.

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/ext/socket/socket.c
    branches/ruby_1_9_1/test/socket/test_socket.rb

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 21536)
+++ ruby_1_9_1/ChangeLog	(revision 21537)
@@ -1,3 +1,9 @@
+Tue Jan 13 00:57:56 2009  Tanaka Akira  <akr@f...>
+
+	* ext/socket/socket.c (sock_s_unpack_sockaddr_in): check too short
+	  sockaddr.
+	  (sock_s_unpack_sockaddr_un): ditto.
+
 Mon Jan 12 17:23:05 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* lib/test/unit/assertions.rb (assert_nothing_raised): removes the
Index: ruby_1_9_1/ext/socket/socket.c
===================================================================
--- ruby_1_9_1/ext/socket/socket.c	(revision 21536)
+++ ruby_1_9_1/ext/socket/socket.c	(revision 21537)
@@ -3484,6 +3484,11 @@
     VALUE host;
 
     sockaddr = (struct sockaddr_in*)StringValuePtr(addr);
+    if (RSTRING_LEN(addr) <
+        (char*)&((struct sockaddr *)sockaddr)->sa_family +
+        sizeof(((struct sockaddr *)sockaddr)->sa_family) -
+        (char*)sockaddr)
+        rb_raise(rb_eArgError, "too short sockaddr");
     if (((struct sockaddr *)sockaddr)->sa_family != AF_INET
 #ifdef INET6
         && ((struct sockaddr *)sockaddr)->sa_family != AF_INET6
@@ -3530,6 +3535,11 @@
     VALUE path;
 
     sockaddr = (struct sockaddr_un*)StringValuePtr(addr);
+    if (RSTRING_LEN(addr) <
+        (char*)&((struct sockaddr *)sockaddr)->sa_family +
+        sizeof(((struct sockaddr *)sockaddr)->sa_family) -
+        (char*)sockaddr)
+        rb_raise(rb_eArgError, "too short sockaddr");
     if (((struct sockaddr *)sockaddr)->sa_family != AF_UNIX) {
         rb_raise(rb_eArgError, "not an AF_UNIX sockaddr");
     }
Index: ruby_1_9_1/test/socket/test_socket.rb
===================================================================
--- ruby_1_9_1/test/socket/test_socket.rb	(revision 21536)
+++ ruby_1_9_1/test/socket/test_socket.rb	(revision 21537)
@@ -82,6 +82,8 @@
     assert_raise(ArgumentError) { Socket.unpack_sockaddr_un(sockaddr_in) }
     sockaddr_un = Socket.sockaddr_un("/tmp/s")
     assert_raise(ArgumentError) { Socket.unpack_sockaddr_in(sockaddr_un) }
+    assert_raise(ArgumentError) { Socket.unpack_sockaddr_in("") }
+    assert_raise(ArgumentError) { Socket.unpack_sockaddr_un("") }
   end if Socket.respond_to?(:sockaddr_un)
 
   def test_sysaccept

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

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