From 46e7e1f9ffe5428871319718024b4707bc5ce27d Mon Sep 17 00:00:00 2001 From: naruse Date: Tue, 29 Mar 2016 07:44:18 +0000 Subject: merge revision(s) 54105,54108,54136,54138: [Backport #12188] * marshal.c (r_object0): Fix Marshal crash for corrupt extended object. * marshal.c (r_object0): raise ArgumentError when linking to undefined object. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54380 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_marshal.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 8377de2155..e2e321bb41 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -718,4 +718,22 @@ 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] + assert_ruby_status(opt, "Marshal.load(#{crash.dump})") + end + + def test_marshal_load_r_prepare_reference_crash + crash = "\x04\bI/\x05\x00\x06:\x06E{\x06@\x05T" + + opt = %w[--disable=gems] + assert_separately(opt, <<-RUBY) + assert_raise_with_message(ArgumentError, /bad link/) do + Marshal.load(#{crash.dump}) + end + RUBY + end end -- cgit v1.2.3