Fixed command Injection

* lib/resolv.rb (Resolv::Config.parse_resolv_conf): fixed
  potential command injection by use of Kernel#open.
  [ruby-core:84347] [Bug #14205]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-12-20 04:25:01 +00:00
parent c08e8886ba
commit cdf1b85ae7
3 changed files with 22 additions and 1 deletions

View file

@ -27,4 +27,15 @@ class TestResolvAddr < Test::Unit::TestCase
end
end
end
def test_hosts_by_command
Dir.mktmpdir do |dir|
Dir.chdir(dir) do
hosts = Resolv::Hosts.new("|echo error")
assert_raise(Errno::ENOENT) do
hosts.each_name("") {}
end
end
end
end
end