summaryrefslogtreecommitdiff
path: root/test/resolv
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-20 04:25:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-20 04:25:01 +0000
commitcdf1b85ae79cd4fe3995a72b6b861d8eb2a9d664 (patch)
tree1c82a34ed101c31b778fd36378e24690c0505e4f /test/resolv
parentc08e8886badd47890a54bdc54f1c09de7ad5c8e8 (diff)
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
Diffstat (limited to 'test/resolv')
-rw-r--r--test/resolv/test_addr.rb11
-rw-r--r--test/resolv/test_dns.rb10
2 files changed, 21 insertions, 0 deletions
diff --git a/test/resolv/test_addr.rb b/test/resolv/test_addr.rb
index 4a2df5bfca..78a28c9633 100644
--- a/test/resolv/test_addr.rb
+++ b/test/resolv/test_addr.rb
@@ -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
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
index f21a094b20..8236078374 100644
--- a/test/resolv/test_dns.rb
+++ b/test/resolv/test_dns.rb
@@ -179,6 +179,16 @@ class TestResolvDNS < Test::Unit::TestCase
end
end
+ def test_resolv_conf_by_command
+ Dir.mktmpdir do |dir|
+ Dir.chdir(dir) do
+ assert_raise(Errno::ENOENT) do
+ Resolv::DNS::Config.parse_resolv_conf("|echo foo")
+ end
+ end
+ end
+ end
+
def test_dots_diffences
name1 = Resolv::DNS::Name.create("example.org")
name2 = Resolv::DNS::Name.create("ex.ampl.eo.rg")