pack.c: fix buffer overrun

* pack.c (encodes): fix buffer overrun by tail_lf.  Thanks to
  Mamoru Tasaka and Tomas Hoger.  [ruby-core:63604] [Bug #10019]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-07-11 01:09:05 +00:00
parent 70451a56ed
commit 8a608d2b1f
3 changed files with 18 additions and 3 deletions

View file

@ -550,6 +550,14 @@ EXPECTED
assert_equal(["\0"], "AA\n".unpack("m"))
assert_equal(["\0"], "AA=\n".unpack("m"))
assert_equal(["\0\0"], "AAA\n".unpack("m"))
bug10019 = '[ruby-core:63604] [Bug #10019]'
size = ((4096-4)/4*3+1)
assert_separately(%W[- #{size} #{bug10019}], <<-'end;')
size = ARGV.shift.to_i
bug = ARGV.shift
assert_equal(size, ["a"*size].pack("m#{size+2}").unpack("m")[0].size, bug)
end;
end
def test_pack_unpack_m0