Subject: | Net::DNS is failing well-formed calls to RR methods complaining about wrong type of RR |
I have found a case where, even though I have checked that a RR is of the correct type, calling a method appropriate to that RR fails. Here's what I narrowed it down to:
#!/usr/bin/perl -w
require 5.6.0;
use strict;
use Data::Dumper;
use Net::DNS;
my $res=new Net::DNS::Resolver;
my $pkt=$res->query('uucp-gw-2.pa.dec.com', 'A');
foreach ($pkt->answer) {
next if $_->type ne 'A';
my $ip=$_->ipaddress;
print Data::Dumper->Dump
(
[ $_, $ip, $Net::DNS::VERSION ],
[ qw( _ ip Net::DNS::VERSION ) ]
);
}
__END__
That script outputs the following:
$ perl net-dns-bugtest.pl
***
*** WARNING!!! The program has attempted to call the method
*** "ipaddress" for the following RR object:
***
*** uucp-gw-2.pa.dec.com. 6217 IN A 204.123.2.19
***
*** This object doesn't have a method "ipaddress". THIS IS A BUG
*** IN THE CALLING SOFTWARE, which has incorrectly assumed that
*** the object would be of a particular type. The calling
*** software should check the type of each RR object before
*** calling any of its methods.
***
*** Net::DNS has returned undef to the caller.
***
at net-dns-bugtest.pl line 12
$_ = bless( {
'rdlength' => 4,
'ttl' => 6217,
'name' => 'uucp-gw-2.pa.dec.com',
'address' => '204.123.2.19',
'class' => 'IN',
'type' => 'A',
'rdata' => 'Ì{'
}, 'Net::DNS::RR::A' );
$ip = undef;
$Net::DNS::VERSION = '0.48';
As you can see, it's definitely an A RR that I'm calling the ipaddress method on, but that call fails with an error. It succeeds on other hostnames I've tried, and dig works on that hostname.
This is running on Debian 'sarge' using its packages of Perl 5.8.4 and Net::DNS 0.48.