diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-14 18:36:14 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-03-14 18:36:14 +0000 |
commit | fa0e37646ad58f1f4d5c70e6d5bf566a0f51fbf4 (patch) | |
tree | f66a6b36d6cb8dc3001489c3b86a34d6657fe88e | |
parent | 4358ff468b7dae1910dd8c112f9d947a620ef03c (diff) |
* marshal.c (r_object0): Fix Marshal crash for corrupt extended object.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | marshal.c | 2 | ||||
-rw-r--r-- | test/ruby/test_marshal.rb | 11 |
3 files changed, 16 insertions, 1 deletions
@@ -1,3 +1,7 @@ +Tue Mar 15 03:35:04 2016 Eric Hodel <[email protected]> + + * marshal.c (r_object0): Fix Marshal crash for corrupt extended object. + Tue Mar 15 01:22:27 2016 Charles Oliver Nutter <[email protected]> * test/ruby/test_rubyoptions.rb: make version matching support @@ -1585,6 +1585,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod) { 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, VALUE extmod) } 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); diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 8377de2155..49a8511e8e 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -718,4 +718,15 @@ class TestMarshal < Test::Unit::TestCase 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 |