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

ruby-changes:22757

From: naruse <ko1@a...>
Date: Sat, 25 Feb 2012 16:40:15 +0900 (JST)
Subject: [ruby-changes:22757] naruse:r34806 (ruby_1_9_3): merge revision(s) 34803:

naruse	2012-02-25 16:39:32 +0900 (Sat, 25 Feb 2012)

  New Revision: 34806

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

  Log:
    merge revision(s) 34803:
    
    * complex.c (nucomp_marshal_load): raise error on invalid data.
      reported by John Firebaugh [ruby-core:42860] [Bug #6076]

  Modified files:
    branches/ruby_1_9_3/ChangeLog
    branches/ruby_1_9_3/complex.c
    branches/ruby_1_9_3/rational.c
    branches/ruby_1_9_3/test/ruby/test_marshal.rb
    branches/ruby_1_9_3/version.h

Index: ruby_1_9_3/complex.c
===================================================================
--- ruby_1_9_3/complex.c	(revision 34805)
+++ ruby_1_9_3/complex.c	(revision 34806)
@@ -1260,6 +1260,8 @@
 {
     get_dat1(self);
     Check_Type(a, T_ARRAY);
+    if (RARRAY_LEN(a) != 2)
+	rb_raise(rb_eArgError, "marshaled complex must have an array whose length is 2 but %ld", RARRAY_LEN(a));
     dat->real = RARRAY_PTR(a)[0];
     dat->imag = RARRAY_PTR(a)[1];
     rb_copy_generic_ivar(self, a);
Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 34805)
+++ ruby_1_9_3/ChangeLog	(revision 34806)
@@ -1,3 +1,8 @@
+Sat Feb 25 16:39:13 2012  NARUSE, Yui  <naruse@r...>
+
+	* complex.c (nucomp_marshal_load): raise error on invalid data.
+	  reported by John Firebaugh [ruby-core:42860] [Bug #6076]
+
 Fri Feb 24 23:49:05 2012  Marc-Andre Lafortune  <ruby-core@m...>
 
 	* lib/ostruct.rb (delete_field): Bug fix so previous value is
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 34805)
+++ ruby_1_9_3/version.h	(revision 34806)
@@ -1,10 +1,10 @@
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 143
+#define RUBY_PATCHLEVEL 144
 
-#define RUBY_RELEASE_DATE "2012-02-24"
+#define RUBY_RELEASE_DATE "2012-02-25"
 #define RUBY_RELEASE_YEAR 2012
 #define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 24
+#define RUBY_RELEASE_DAY 25
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/test/ruby/test_marshal.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_marshal.rb	(revision 34805)
+++ ruby_1_9_3/test/ruby/test_marshal.rb	(revision 34806)
@@ -469,4 +469,18 @@
     assert_equal(o1.class, o2.class)
     assert_equal(o1.foo, o2.foo)
   end
+
+  def test_marshal_complex
+    assert_raise(ArgumentError){Marshal.load("\x04\bU:\fComplex[\x05")}
+    assert_raise(ArgumentError){Marshal.load("\x04\bU:\fComplex[\x06i\x00")}
+    assert_equal(Complex(1, 2), Marshal.load("\x04\bU:\fComplex[\ai\x06i\a"))
+    assert_raise(ArgumentError){Marshal.load("\x04\bU:\fComplex[\bi\x00i\x00i\x00")}
+  end
+
+  def test_marshal_rational
+    assert_raise(ArgumentError){Marshal.load("\x04\bU:\rRational[\x05")}
+    assert_raise(ArgumentError){Marshal.load("\x04\bU:\rRational[\x06i\x00")}
+    assert_equal(Rational(1, 2), Marshal.load("\x04\bU:\rRational[\ai\x06i\a"))
+    assert_raise(ArgumentError){Marshal.load("\x04\bU:\rRational[\bi\x00i\x00i\x00")}
+  end
 end
Index: ruby_1_9_3/rational.c
===================================================================
--- ruby_1_9_3/rational.c	(revision 34805)
+++ ruby_1_9_3/rational.c	(revision 34806)
@@ -1606,6 +1606,8 @@
 {
     get_dat1(self);
     Check_Type(a, T_ARRAY);
+    if (RARRAY_LEN(a) != 2)
+	rb_raise(rb_eArgError, "marshaled rational must have an array whose length is 2 but %ld", RARRAY_LEN(a));
     dat->num = RARRAY_PTR(a)[0];
     dat->den = RARRAY_PTR(a)[1];
     rb_copy_generic_ivar(self, a);

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

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