summaryrefslogtreecommitdiff
path: root/test/ruby/test_marshal.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-15 00:58:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-15 00:58:09 +0000
commit14264f5f622f7a2b7688edfdcfad0aa6d8db155d (patch)
tree223b96f857250ab69187ff081f63b1d596bae98d /test/ruby/test_marshal.rb
parent297d2e05cbb0ff8314cf9f595ba8916ef23b0ad3 (diff)
* marshal.c (r_bytes0): check if source has enough data.
[ruby-dev:32054] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_marshal.rb')
-rw-r--r--test/ruby/test_marshal.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index d438ef4d85..049db1221e 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -52,4 +52,24 @@ class TestMarshal < Test::Unit::TestCase
TestMarshal::StructInvalidMembers.members
}
end
+
+ class C
+ def initialize(str)
+ @str = str
+ end
+ def _dump(limit)
+ @str
+ end
+ def self._load(s)
+ new(s)
+ end
+ end
+
+ def test_too_long_string
+ (data = Marshal.dump(C.new("a")))[-2, 1] = "\003\377\377\377"
+ e = assert_raise(ArgumentError, "[ruby-dev:32054]") {
+ Marshal.load(data)
+ }
+ assert_equal("marshal data too short", e.message)
+ end
end