Resolv::IPv6.create: avoid modifying frozen string literal

* lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen
* test/resolv/test_dns.rb (test_ipv6_create): test for above
  [Bug #11910] [ruby-core:72559]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2015-12-28 20:31:10 +00:00
Родитель d21c54ffbd
Коммит a3b53cd991
3 изменённых файлов: 17 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Tue Dec 29 05:30:30 2015 Eric Wong <e@80x24.org>
* lib/resolv.rb (Resolv::IPv6.create): avoid modifying frozen
* test/resolv/test_dns.rb (test_ipv6_create): test for above
[Bug #11910] [ruby-core:72559]
Mon Dec 28 14:55:57 2015 Kuniaki IGARASHI <igaiga@gmail.com>
* test/ruby/test_string.rb (TestString#test_rstrip_bang): Add test

Просмотреть файл

@ -2451,14 +2451,14 @@ class Resolv
when IPv6
return arg
when String
address = ''
address = ''.b
if Regex_8Hex =~ arg
arg.scan(/[0-9A-Fa-f]+/) {|hex| address << [hex.hex].pack('n')}
elsif Regex_CompressedHex =~ arg
prefix = $1
suffix = $2
a1 = ''
a2 = ''
a1 = ''.b
a2 = ''.b
prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
omitlen = 16 - a1.length - a2.length
@ -2474,8 +2474,8 @@ class Resolv
elsif Regex_CompressedHex4Dec =~ arg
prefix, suffix, a, b, c, d = $1, $2, $3.to_i, $4.to_i, $5.to_i, $6.to_i
if (0..255) === a && (0..255) === b && (0..255) === c && (0..255) === d
a1 = ''
a2 = ''
a1 = ''.b
a2 = ''.b
prefix.scan(/[0-9A-Fa-f]+/) {|hex| a1 << [hex.hex].pack('n')}
suffix.scan(/[0-9A-Fa-f]+/) {|hex| a2 << [hex.hex].pack('n')}
omitlen = 12 - a1.length - a2.length

Просмотреть файл

@ -199,6 +199,12 @@ class TestResolvDNS < Test::Unit::TestCase
assert_equal(expected, labels)
end
def test_ipv6_create
ref = '[Bug #11910] [ruby-core:72559]'
assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1')
assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1:127.0.0.1')
end
def test_too_big_label_address
n = 2000
m = Resolv::DNS::Message::MessageEncoder.new {|msg|