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

ruby-changes:42031

From: drbrain <ko1@a...>
Date: Tue, 15 Mar 2016 03:36:22 +0900 (JST)
Subject: [ruby-changes:42031] drbrain:r54105 (trunk): * marshal.c (r_object0): Fix Marshal crash for corrupt extended object.

drbrain	2016-03-15 03:36:14 +0900 (Tue, 15 Mar 2016)

  New Revision: 54105

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

  Log:
    * marshal.c (r_object0): Fix Marshal crash for corrupt extended object.

  Modified files:
    trunk/ChangeLog
    trunk/marshal.c
    trunk/test/ruby/test_marshal.rb
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb	(revision 54104)
+++ test/ruby/test_marshal.rb	(revision 54105)
@@ -718,4 +718,15 @@ class TestMarshal < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_marshal.rb#L718
     obj = [str, str]
     assert_equal(['X', 'X'], Marshal.load(Marshal.dump(obj), ->(v) { v == str ? v.upcase : v }))
   end
+
+  def test_marshal_load_extended_class_crash
+    crash = "\x04\be:\x0F\x00omparableo:\vObject\x00"
+
+    opt = %w[--disable=gems]
+    args = [opt, "Marshal.load(#{crash.dump})", true, true]
+    out, err, status = EnvUtil.invoke_ruby(*args)
+
+    assert_empty err
+    assert_predicate(status, :success?)
+  end
 end
Index: marshal.c
===================================================================
--- marshal.c	(revision 54104)
+++ marshal.c	(revision 54105)
@@ -1585,6 +1585,7 @@ r_object0(struct load_arg *arg, int *ivp https://github.com/ruby/ruby/blob/trunk/marshal.c#L1585
 	{
 	    VALUE path = r_unique(arg);
 	    VALUE m = rb_path_to_class(path);
+	    if (NIL_P(extmod)) extmod = rb_ary_tmp_new(0);
 
 	    if (RB_TYPE_P(m, T_CLASS)) { /* prepended */
 		VALUE c;
@@ -1604,7 +1605,6 @@ r_object0(struct load_arg *arg, int *ivp https://github.com/ruby/ruby/blob/trunk/marshal.c#L1605
 	    }
 	    else {
 		must_be_module(m, path);
-		if (NIL_P(extmod)) extmod = rb_ary_tmp_new(0);
 		rb_ary_push(extmod, m);
 
 		v = r_object0(arg, 0, extmod);
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 54104)
+++ ChangeLog	(revision 54105)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Mar 15 03:35:04 2016  Eric Hodel  <drbrain@s...>
+
+	* marshal.c (r_object0): Fix Marshal crash for corrupt extended object.
+
 Tue Mar 15 01:22:27 2016  Charles Oliver Nutter  <headius@h...>
 
 	* test/ruby/test_rubyoptions.rb: make version matching support

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

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