diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-07 16:50:57 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-07 16:50:57 +0000 |
commit | b296c4818c5b42fd11675f6cc8082be1a19e13bc (patch) | |
tree | 4472d054781615c68f99b564b272be9172c841cb /test | |
parent | 56f39ded333293a4489cd0eb0b75e3801fd57a9c (diff) |
merge revision(s) 13699:13704:
* marshal.c (r_bytes0): refined length check. [ruby-dev:32059]
* 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_6@16903 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 |