diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-15 00:58:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-10-15 00:58:09 +0000 |
commit | d95e0da764b8870a5c5278e7f2375c4adf92e4f4 (patch) | |
tree | c85fe2c53f6530e912e1ac8cd756ebcf3c226c53 /test | |
parent | ddeb0a4183c74637c23560c9c06c6470721019c9 (diff) |
* marshal.c (r_bytes0): check if source has enough data.
[ruby-dev:32054]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_marshal.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 9c9fd9470b..11f3583076 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -45,4 +45,24 @@ class TestMarshal < Test::Unit::TestCase assert_equal(a, b) } 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 |