[patch] perlbal dies invalid host passed to sockaddr_in
Fred Moyer
fred at redhotpenguin.com
Thu Dec 6 20:29:21 UTC 2007
Greetings,
I happened on this bug by chance when I passed an unresolvable hostname in
a request to perlbal, and Socket::sockaddr_in croaked and killed perlbal.
What is interesting is that the first time I passed the invalid hostname,
the ip resolved to 127.0.0.1, but didn't resolve the second time an
invalid hostname was passed, and perlbal died. I didn't take the time to
figure out why.
This is likely not a big problem for anyone but me but here is the patch
to fix it nonetheless.
Index: lib/Perlbal/BackendHTTP.pm
===================================================================
--- lib/Perlbal/BackendHTTP.pm (revision 734)
+++ lib/Perlbal/BackendHTTP.pm (working copy)
@@ -71,9 +71,14 @@
Perlbal::log('crit', "Error creating socket: $!");
return undef;
}
-
+ my $inet_aton = Socket::inet_aton($ip);
+ unless ($inet_aton) {
+ Perlbal::log('crit', "inet_aton failed creating socket for $ip");
+ return undef;
+ }
+
IO::Handle::blocking($sock, 0);
- connect $sock, Socket::sockaddr_in($port, Socket::inet_aton($ip));
+ connect $sock, Socket::sockaddr_in($port, $inet_aton);
my $self = fields::new($class);
$self->SUPER::new($sock);
More information about the perlbal
mailing list