Skip Menu |

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

Report information
The Basics
Id: 130384
Status: rejected
Priority: 0/
Queue: Net-DNS

People
Owner: Nobody in particular
Requestors: t.maedel [...] alfeld.de
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Nameserver infinite loop with invalid bind address
Date: Mon, 26 Aug 2019 23:57:17 +0200
To: bug-Net-DNS [...] rt.cpan.org
From: Tobias Mädel <t.maedel [...] alfeld.de>
Hi, when Net:DNS:Nameserver is used with an invalid address for the local bind address, it will start running in an infinite loop and use 100% of the available CPU power. This is because in Nameserver.pm, errors while creating the UDP and TCP sockets are only handled with a carp. I'm not too familiar with Perl, but maybe "croak" would be more appropriate? I don't think the program should be running after an unsuccessful socket creation. To test the bug, use the Nameserver example code and add LocalAddr => [ "::1234" ], to the array of parameters for the nameserver object. After complaining about "Couldn't create UDP socket: Cannot assign requested address at test.pl line 36." it will start writing "TCP connection closed by peer before we could accept it. Waiting for connections..." and use all available CPU. System info if it's interesting: perl5 (revision 5 version 30 subversion 0) Net::DNS - 1.20 Tested on Arch & Debian Thanks, Tobias @manawyrm
Easy to see what is going on if you fire it up using debugger: main::(test.pl:36): my $ns = new Net::DNS::Nameserver( main::(test.pl:37): LocalAddr => [ '::1', '127.0.0.1', '::1234' ], main::(test.pl:38): LocalPort => 15353, main::(test.pl:39): ReplyHandler => \&reply_handler, main::(test.pl:40): Verbose => 1 main::(test.pl:41): ) main::(test.pl:42): || die "couldn't create nameserver object\n"; DB<1> n Creating TCP socket ::1#15353 - done. Creating UDP socket ::1#15353 - done. Creating TCP socket 127.0.0.1#15353 - done. Creating UDP socket 127.0.0.1#15353 - done. Creating TCP socket ::1234#15353 - done. Creating UDP socket ::1234#15353 - Couldn't create UDP socket: Cannot assign requested address at test.pl line 36. at blib/lib/Net/DNS/Nameserver.pm line 145. Net::DNS::Nameserver::new("Net::DNS::Nameserver", "LocalAddr", ARRAY(0x5568bcee4d30), "LocalPort", 15353, "ReplyHandler", CODE(0x5568bd4919a0), "Verbose", ...) called at test.pl line 36 IO::Socket::IP is unable to assign your bogus local address to a UDP socket. The same error is not detected for a TCP socket and is the root cause of the bizarre behaviour you describe. The bug lies in IO::Socket::IP, not Net::DNS::Nameserver