diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-13 09:33:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-12-13 09:33:40 +0000 |
commit | d10d5a974d81628605cf4d69b9e1a9b13fd43651 (patch) | |
tree | 440ede7e1c0b7220160995858d84112dbe578844 /test/ruby/test_pack.rb | |
parent | db48c307944a9a18877236bdf9e9b778875f38ed (diff) | |
download | ruby-d10d5a974d81628605cf4d69b9e1a9b13fd43651.tar.gz |
pack.c: check index range
* pack.c (pack_pack): always check index range against the
receiver array length, which can be shortened by elements
conversion. reported by Marcin 'Icewall' Noga of Cisco Talos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53080 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_pack.rb')
-rw-r--r-- | test/ruby/test_pack.rb | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 8dbfd95809..d696dd70a1 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -794,4 +794,23 @@ EXPECTED } } end + + def test_pack_resize + assert_separately([], <<-'end;') + ary = [] + obj = Class.new { + define_method(:to_str) { + ary.clear() + ary = nil + GC.start + "TALOS" + } + }.new + + ary.push(obj) + ary.push(".") + + assert_raise_with_message(ArgumentError, /too few/) {ary.pack("AA")} + end; + end end |