Perlbal - [patch] perlbal dies invalid host passed to sockaddr_in

This is Interesting: Free IT Magazines  
Home > Archive > Perlbal > December 2007 > [patch] perlbal dies invalid host passed to sockaddr_in





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author [patch] perlbal dies invalid host passed to sockaddr_in
Fred Moyer

2007-12-06, 7:11 pm

Greetings,

I happened on this bug by chance when I passed an unresolvable hostname i=
n
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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
3D=3D=3D=3D
--- 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 =3D 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 =3D fields::new($class);
$self->SUPER::new($sock);


Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com