Skip Menu |

This queue is for tickets about the Net-DNS CPAN distribution.

Report information
The Basics
Id: 2910
Status: resolved
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: cfaber [...] fpsn.net
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in:
  • 0.20
  • 0.38
Fixed in: (no value)



Subject: Net::DNS::Resolver doesn't do sanity checking on nameserver entries with in resolv.conf
Because Net::DNS::Resolver's resolv.conf parser fails to do any sainty checking on the data being provided to it, some people have been having issues. The error commonly seen is stuff like: "Bad arg length for Socket::pack_sockaddr_in, length is 0, should be 4 at /usr/local/lib/perl5/5.8.0/i386-freebsd/Socket.pm line 373." etc. This is caused by the send_udp() function mapping the IPv6 polluted name servers list at $self->{'nameservers'} and attempting to pass an invalid address to inet_aton(). The patch I've attached corrects this pollution by only allowing dotted quad addresses, though it doesn't fully check to see if the address is valid or not, inet_aton should handle that just fine.
--- lib/Net/DNS/Resolver.pm Thu Jun 5 17:42:58 2003 +++ lib/Net/DNS/Resolver.pm Mon Jul 7 15:23:44 2003 @@ -345,9 +345,16 @@ }; /^\s*nameserver\s+(.*)/ && do { - foreach my $ns (split(' ', $1)) { - $ns = '0.0.0.0' if $ns eq '0'; - push @ns, $ns; + READ_NS: foreach my $ns (split(/\s+/, $1)) { + if($ns eq '0'){ + $ns = '0.0.0.0'; + } elsif($ns =~ /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/){ + # Sanity check for IPv4 name servers. + push @ns, $ns; + } elsif($ns =~ /^[0-9A-Fa-f]{4}\:/){ + # Appears to be an IPv6 NS, - ignore for now. + next READ_NS; + } } last SWITCH; };