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

ruby-changes:4959

From: ko1@a...
Date: Sun, 18 May 2008 02:56:58 +0900 (JST)
Subject: [ruby-changes:4959] mame - Ruby:r16452 (trunk): * pack.c (pack_pack): check errno to detect error of ruby_strtoul.

mame	2008-05-18 02:56:41 +0900 (Sun, 18 May 2008)

  New Revision: 16452

  Modified files:
    trunk/ChangeLog
    trunk/pack.c
    trunk/test/ruby/test_pack.rb
    trunk/version.h

  Log:
    * pack.c (pack_pack): check errno to detect error of ruby_strtoul.
    
    * pack.c (pack_unpack): ditto.
    
    * test/ruby/test_pack.rb: add a test for above.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_pack.rb?r1=16452&r2=16451&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/version.h?r1=16452&r2=16451&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16452&r2=16451&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/pack.c?r1=16452&r2=16451&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16451)
+++ ChangeLog	(revision 16452)
@@ -1,3 +1,11 @@
+Sun May 18 02:54:46 2008  Yusuke Endoh  <mame@t...>
+
+	* pack.c (pack_pack): check errno to detect error of ruby_strtoul.
+
+	* pack.c (pack_unpack): ditto.
+
+	* test/ruby/test_pack.rb: add a test for above.
+
 Sat May 17 23:53:57 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* file.c (file_expand_path): fix for short file name on Cygwin.
Index: pack.c
===================================================================
--- pack.c	(revision 16451)
+++ pack.c	(revision 16452)
@@ -12,6 +12,7 @@
 #include "ruby/ruby.h"
 #include <sys/types.h>
 #include <ctype.h>
+#include <errno.h>
 
 #define SIZE16 2
 #define SIZE32 4
@@ -491,7 +492,11 @@
 	    p++;
 	}
 	else if (ISDIGIT(*p)) {
+	    errno = 0;
 	    len = STRTOUL(p, (char**)&p, 10);
+	    if (errno) {
+		rb_raise(rb_eRangeError, "pack length too big");
+	    }
 	}
 	else {
 	    len = 1;
@@ -1350,7 +1355,11 @@
 	    p++;
 	}
 	else if (ISDIGIT(*p)) {
+	    errno = 0;
 	    len = STRTOUL(p, (char**)&p, 10);
+	    if (errno) {
+		rb_raise(rb_eRangeError, "pack length too big");
+	    }
 	}
 	else {
 	    len = (type != '@');
Index: version.h
===================================================================
--- version.h	(revision 16451)
+++ version.h	(revision 16452)
@@ -1,7 +1,7 @@
 #define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-05-17"
+#define RUBY_RELEASE_DATE "2008-05-18"
 #define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080517
+#define RUBY_RELEASE_CODE 20080518
 #define RUBY_PATCHLEVEL 0
 
 #define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
 #define RUBY_VERSION_TEENY 0
 #define RUBY_RELEASE_YEAR 2008
 #define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 17
+#define RUBY_RELEASE_DAY 18
 
 #ifdef RUBY_EXTERN
 RUBY_EXTERN const char ruby_version[];
Index: test/ruby/test_pack.rb
===================================================================
--- test/ruby/test_pack.rb	(revision 16451)
+++ test/ruby/test_pack.rb	(revision 16452)
@@ -441,4 +441,8 @@
       end.join
     end
   end
+
+  def test_length_too_big
+    assert_raise(RangeError) { [].pack("C100000000000000000000") }
+  end
 end

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

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