summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-25 09:19:56 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-03-25 09:19:56 +0000
commit477c282a079a1784a0b8c236e7449712be07cae4 (patch)
tree45fcd3fcae0c6ebf565fa12caaa4c4a1883c2959 /test
parentd86cba89d8ffd9339bf3a4755774dd1f8a78cc52 (diff)
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_1@54274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_marshal.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index 14c49faca3..8e0bca46ba 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -1,5 +1,6 @@
require 'test/unit'
require 'tempfile'
+require_relative 'envutil'
require_relative 'marshaltestlib'
class TestMarshal < Test::Unit::TestCase
@@ -612,4 +613,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