From 77d12f842accdb4b5ef31ce99b09568096ea4c8b Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 15 Oct 2007 00:58:09 +0000 Subject: * 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 --- test/ruby/test_marshal.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/ruby') 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 -- cgit