summaryrefslogtreecommitdiff
path: root/test/resolv/test_dns.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-14 02:26:48 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-01-14 02:26:48 +0000
commit2b2450ba4bee563e33af0325b7fde8cb1bfd6899 (patch)
tree4a868d34871ebc8b83171fb8455099827e0b7ead /test/resolv/test_dns.rb
parentaf5eae433239cfabeed4d11ab541f59c99968fb7 (diff)
Made #decode_rdata client to catch errors
* lib/resolv.rb (Resolv::DNS::Message::MessageDecoder#get_rr): re-raise an exception from decode_rdata as DecodeError, so it can report them to the top in more informative way. It was not reflecting on errors of data and thus breaking. Client code expects `DecodeError` and knows how to handle broken messages. [Fix GH-1511] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57325 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/resolv/test_dns.rb')
-rw-r--r--test/resolv/test_dns.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/resolv/test_dns.rb b/test/resolv/test_dns.rb
index d1431c1..f21a094 100644
--- a/test/resolv/test_dns.rb
+++ b/test/resolv/test_dns.rb
@@ -205,6 +205,21 @@ class TestResolvDNS < Test::Unit::TestCase
assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1:127.0.0.1')
end
+ def test_ipv6_should_be_16
+ ref = '[rubygems:1626]'
+
+ broken_message =
+ "\0\0\0\0\0\0\0\0\0\0\0\1" \
+ "\x03ns2\bdnsimple\x03com\x00" \
+ "\x00\x1C\x00\x01\x00\x02OD" \
+ "\x00\x10$\x00\xCB\x00 I\x00\x01\x00\x00\x00\x00"
+
+ e = assert_raise_with_message(Resolv::DNS::DecodeError, /IPv6 address must be 16 bytes/, ref) do
+ Resolv::DNS::Message.decode broken_message
+ end
+ assert_kind_of(ArgumentError, e.cause)
+ end
+
def test_too_big_label_address
n = 2000
m = Resolv::DNS::Message::MessageEncoder.new {|msg|