mirror of
https://github.com/ruby/ruby.git
synced 2025-09-22 03:53:58 +02:00
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
This commit is contained in:
parent
db48c30794
commit
d10d5a974d
3 changed files with 30 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue