Subject: | Net::DNS::Resolver warns "Use of uninitialized value in length" when called from Net::DNS::Nameserver |
Using Net::DNS 0.76 or 0.77, and perl 5.8.9, now reports a warning:
$ perl -we 'use Net::DNS::Nameserver; Net::DNS::Nameserver->new(
LocalAddr=>"127.0.0.1", LocalPort=>17733, ReplyHandler=>sub{})'
Use of uninitialized value in length at ../Net/DNS/Resolver/Base.pm line 318.
This happens because Net::DNS::Nameserver::new calls
$resolver->nameservers(undef); (near line 92)
and the Net::DNS::Resolver::Base::nameservers() now checks
for length() instead of defined():
sub nameservers {
my $self = shift;
my ( @ipv4, @ipv6 );
foreach my $ns (@_) {
next unless length($ns);
...
The change in Net::DNS::Resolver::Base was introduced in Net::DNS 0.76.
Previously (in 0.75) the code there checked for defined():
foreach my $ns (@_) {
next unless defined($ns);
Note that newer versions of perl no longer report a warning when
length() is called on undef, but perl 5.8.9 does produce a warning.
Not sure with what version of perl the change was made.
Regardless, it is worth avoiding the issue (e.g. reported by a test
dnsbl_subtests.t in SpamAssassin) to avoid unnecessary problem reports.