From b18c513e24dad5f464701a4ad49ac699f435bbbe Mon Sep 17 00:00:00 2001 From: usa Date: Wed, 17 Oct 2018 15:09:24 +0000 Subject: merge revision(s) 65125: infect taint flag on Array#pack and String#unpack with the directives "B", "b", "H" and "h". * pack.c (pack_pack, pack_unpack_internal): infect taint flag. * test/ruby/test_pack.rb: add test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@65130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_pack.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index b59faec9f3..76843b2eae 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -829,4 +829,20 @@ EXPECTED ret = []; "A".unpack("B*") {|v| ret << v } assert_equal ["01000001"], ret end + + def test_pack_infection + tainted_array_string = ["123456"] + tainted_array_string.first.taint + ['a', 'A', 'Z', 'B', 'b', 'H', 'h', 'u', 'M', 'm', 'P', 'p'].each do |f| + assert_predicate(tainted_array_string.pack(f), :tainted?) + end + end + + def test_unpack_infection + tainted_string = "123456" + tainted_string.taint + ['a', 'A', 'Z', 'B', 'b', 'H', 'h', 'u', 'M', 'm'].each do |f| + assert_predicate(tainted_string.unpack(f).first, :tainted?) + end + end end -- cgit v1.2.3