Subject: | Bug in Windows implementation of net-dns |
Perl 5.6.1 activestate build on Windows 2000.
Run the code below, then open a command prompt and do an nslookup, setting server to 127.0.0.1. The net-dns server sleeps before responding (the sleep time emulates the delay a sql server might give under load in my production environment). The net-dns inquiry times out, but because the connection has closed, the thing crashes with the following:
This is the error message:
creating TCP socket...done.
creating UDP socket...done.
waiting for connections...UDP connection from 192.168.1.11:4903
query 3: (shuster.com.federation, IN, A)...NOERROR
writing response...done
waiting for connections...UDP connection from 192.168.1.11:4904
query 4: (shuster.com, IN, A)...NOERROR
writing response...done
waiting for connections...Bad arg length for Socket::unpack_sockaddr_in, length
is 0, should be 16 at C:/Perl/lib/Socket.pm line 312.
Here is the source code:
use strict;
use Net::DNS;
use Net::DNS::Nameserver;
sub reply_handler {
my ($qname, $qclass, $qtype) = @_;
my ($rcode, @ans, @auth, @add);
if ($qtype eq "A") {
my ($ttl, $rdata) = (3600, "10.1.2.3");
push @ans, Net::DNS::RR->new("$qname $ttl $qclass $qtype $rdata");
$rcode = "NOERROR";
} else {
$rcode = "NXDOMAIN";
}
sleep(10);
return ($rcode, \@ans, \@auth, \@add);
}
my $ns = Net::DNS::Nameserver->new(
LocalPort => 53,
ReplyHandler => \&reply_handler,
Verbose => 1
);
if ($ns) {
$ns->main_loop;
} else {
die "couldn't create nameserver object\n";
}
exit;