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:
parent
c08e8886ba
commit
cdf1b85ae7
@ -928,7 +928,7 @@ class Resolv
|
|||||||
nameserver = []
|
nameserver = []
|
||||||
search = nil
|
search = nil
|
||||||
ndots = 1
|
ndots = 1
|
||||||
open(filename, 'rb') {|f|
|
File.open(filename, 'rb') {|f|
|
||||||
f.each {|line|
|
f.each {|line|
|
||||||
line.sub!(/[#;].*/, '')
|
line.sub!(/[#;].*/, '')
|
||||||
keyword, *args = line.split(/\s+/)
|
keyword, *args = line.split(/\s+/)
|
||||||
|
@ -27,4 +27,15 @@ class TestResolvAddr < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
@ -179,6 +179,16 @@ class TestResolvDNS < Test::Unit::TestCase
|
|||||||
end
|
end
|
||||||
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
|
def test_dots_diffences
|
||||||
name1 = Resolv::DNS::Name.create("example.org")
|
name1 = Resolv::DNS::Name.create("example.org")
|
||||||
name2 = Resolv::DNS::Name.create("ex.ampl.eo.rg")
|
name2 = Resolv::DNS::Name.create("ex.ampl.eo.rg")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user