diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-21 09:08:45 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-02-21 09:08:45 +0000 |
commit | 14a34023570a25f926fb1820ad60d0b614fd76e3 (patch) | |
tree | 412870efbaaf5649c739bb768342b6c8e46eec7a | |
parent | 862b86f2e4cc561861053c1485dc378c23ad794f (diff) |
merge revision(s) 44312,44318: [Backport #9273]
* 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/branches/ruby_2_1@45075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | lib/resolv.rb | 4 | ||||
-rw-r--r-- | test/resolv/test_addr.rb | 12 | ||||
-rw-r--r-- | test/resolv/test_dns.rb | 11 | ||||
-rw-r--r-- | version.h | 2 |
5 files changed, 33 insertions, 3 deletions
@@ -1,3 +1,10 @@ +Fri Feb 21 17:42:42 2014 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. + Fri Feb 21 16:47:20 2014 Nobuyoshi Nakada <nobu@ruby-lang.org> * string.c (get_encoding): respect BOM on pseudo encodings. diff --git a/lib/resolv.rb b/lib/resolv.rb index 6d34a67e09..0c2b68ec27 100644 --- a/lib/resolv.rb +++ b/lib/resolv.rb @@ -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+/) diff --git a/test/resolv/test_addr.rb b/test/resolv/test_addr.rb index 84bc8c2d3b..d4728e1b71 100644 --- a/test/resolv/test_addr.rb +++ b/test/resolv/test_addr.rb @@ -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 diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb index 0d9565ef68..07396fb177 100644 --- a/test/resolv/test_dns.rb +++ b/test/resolv/test_dns.rb @@ -1,6 +1,7 @@ require 'test/unit' require 'resolv' require 'socket' +require 'tempfile' class TestResolvDNS < Test::Unit::TestCase def setup @@ -150,4 +151,14 @@ 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 + assert_nothing_raised(ArgumentError, bug9273) do + Resolv::DNS::Config.parse_resolv_conf(tmpfile.path) + end + end + end end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.1.1" #define RUBY_RELEASE_DATE "2014-02-21" -#define RUBY_PATCHLEVEL 41 +#define RUBY_PATCHLEVEL 42 #define RUBY_RELEASE_YEAR 2014 #define RUBY_RELEASE_MONTH 2 |