1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

resolv.rb: no encodings

* lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not
  consider encodings in hosts file.  [ruby-core:59239] [Bug #9273]
* lib/resolv.rb (Resolv::Config.parse_resolv_conf): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-21 03:37:26 +00:00
parent 96225160f6
commit 1ffbe07e17
4 changed files with 34 additions and 2 deletions

View file

@ -1,3 +1,10 @@
Sat Dec 21 12:37:19 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not
consider encodings in hosts file. [ruby-core:59239] [Bug #9273]
* lib/resolv.rb (Resolv::Config.parse_resolv_conf): ditto.
Sat Dec 21 05:43:27 2013 NAKAMURA Usaku <usa@ruby-lang.org>
* tool/make-snapshot: replace RUBY_PATCHLEVEL_STR in version.h to

View file

@ -187,7 +187,7 @@ class Resolv
unless @initialized
@name2addr = {}
@addr2name = {}
open(@filename) {|f|
open(@filename, 'rb') {|f|
f.each {|line|
line.sub!(/#.*/, '')
addr, hostname, *aliases = line.split(/\s+/)
@ -920,7 +920,7 @@ class Resolv
nameserver = []
search = nil
ndots = 1
open(filename) {|f|
open(filename, 'rb') {|f|
f.each {|line|
line.sub!(/[#;].*/, '')
keyword, *args = line.split(/\s+/)

View file

@ -13,4 +13,16 @@ class TestResolvAddr < Test::Unit::TestCase
end
}
end
def test_invalid_byte_comment
bug9273 = '[ruby-core:59239] [Bug #9273]'
Tempfile.open('resolv_test_addr_') do |tmpfile|
tmpfile.print("\xff\x00\x40")
tmpfile.close
hosts = Resolv::Hosts.new(tmpfile.path)
assert_nothing_raised(ArgumentError, bug9273) do
hosts.each_address("") {break}
end
end
end
end

View file

@ -1,6 +1,7 @@
require 'test/unit'
require 'resolv'
require 'socket'
require 'tempfile'
class TestResolvDNS < Test::Unit::TestCase
def setup
@ -150,4 +151,16 @@ class TestResolvDNS < Test::Unit::TestCase
}
end
def test_invalid_byte_comment
bug9273 = '[ruby-core:59239] [Bug #9273]'
Tempfile.open('resolv_test_dns_') do |tmpfile|
tmpfile.print("\xff\x00\x40")
tmpfile.close
Resolv::DNS.open(tmpfile.path) do |dns|
assert_nothing_raised(ArgumentError, bug9273) do
dns.getresources("foo.example.org", Resolv::DNS::Resource::IN::A)
end
end
end
end
end