File tree Expand file tree Collapse file tree 5 files changed +33
-3
lines changed
Expand file tree Collapse file tree 5 files changed +33
-3
lines changed Original file line number Diff line number Diff line change 1+ Fri Feb 21 17:42:42 2014 Nobuyoshi Nakada <
[email protected] >
2+
3+ * lib/resolv.rb (Resolv::Hosts#lazy_initialize): should not
4+ consider encodings in hosts file. [ruby-core:59239] [Bug #9273]
5+
6+ * lib/resolv.rb (Resolv::Config.parse_resolv_conf): ditto.
7+
18Fri Feb 21 16:47:20 2014 Nobuyoshi Nakada <
[email protected] >
29
310 * string.c (get_encoding): respect BOM on pseudo encodings.
Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ def lazy_initialize # :nodoc:
187187 unless @initialized
188188 @name2addr = { }
189189 @addr2name = { }
190- open ( @filename ) { |f |
190+ open ( @filename , 'rb' ) { |f |
191191 f . each { |line |
192192 line . sub! ( /#.*/ , '' )
193193 addr , hostname , *aliases = line . split ( /\s +/ )
@@ -920,7 +920,7 @@ def Config.parse_resolv_conf(filename)
920920 nameserver = [ ]
921921 search = nil
922922 ndots = 1
923- open ( filename ) { |f |
923+ open ( filename , 'rb' ) { |f |
924924 f . each { |line |
925925 line . sub! ( /[#;].*/ , '' )
926926 keyword , *args = line . split ( /\s +/ )
Original file line number Diff line number Diff line change @@ -13,4 +13,16 @@ def test_invalid_ipv4_address
1313 end
1414 }
1515 end
16+
17+ def test_invalid_byte_comment
18+ bug9273 = '[ruby-core:59239] [Bug #9273]'
19+ Tempfile . open ( 'resolv_test_addr_' ) do |tmpfile |
20+ tmpfile . print ( "\xff \x00 \x40 " )
21+ tmpfile . close
22+ hosts = Resolv ::Hosts . new ( tmpfile . path )
23+ assert_nothing_raised ( ArgumentError , bug9273 ) do
24+ hosts . each_address ( "" ) { break }
25+ end
26+ end
27+ end
1628end
Original file line number Diff line number Diff line change 11require 'test/unit'
22require 'resolv'
33require 'socket'
4+ require 'tempfile'
45
56class TestResolvDNS < Test ::Unit ::TestCase
67 def setup
@@ -150,4 +151,14 @@ def test_no_server
150151 }
151152 end
152153
154+ def test_invalid_byte_comment
155+ bug9273 = '[ruby-core:59239] [Bug #9273]'
156+ Tempfile . open ( 'resolv_test_dns_' ) do |tmpfile |
157+ tmpfile . print ( "\xff \x00 \x40 " )
158+ tmpfile . close
159+ assert_nothing_raised ( ArgumentError , bug9273 ) do
160+ Resolv ::DNS ::Config . parse_resolv_conf ( tmpfile . path )
161+ end
162+ end
163+ end
153164end
Original file line number Diff line number Diff line change 11#define RUBY_VERSION "2.1.1"
22#define RUBY_RELEASE_DATE "2014-02-21"
3- #define RUBY_PATCHLEVEL 41
3+ #define RUBY_PATCHLEVEL 42
44
55#define RUBY_RELEASE_YEAR 2014
66#define RUBY_RELEASE_MONTH 2
You can’t perform that action at this time.
0 commit comments