summaryrefslogtreecommitdiffstats
path: root/test
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
commit77d12f842accdb4b5ef31ce99b09568096ea4c8b (patch)
tree223b96f857250ab69187ff081f63b1d596bae98d /test
parented56e8f28424cb73f91f64ad3ac6c998a6b9eaaf (diff)
downloadruby-77d12f842accdb4b5ef31ce99b09568096ea4c8b.tar.gz
ruby-77d12f842accdb4b5ef31ce99b09568096ea4c8b.tar.xz
ruby-77d12f842accdb4b5ef31ce99b09568096ea4c8b.zip
* marshal.c (r_bytes0): check if source has enough data.
[ruby-dev:32054] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-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 d438ef4d8..049db1221 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