[ID 20011126.148] Socket::inet_aton() incorrectly accepts null string
Bob Dalgleish [Mon, 26 Nov 2001 18:47:25 +0000 (12:47 -0600)]
Message-Id: <B8283EBD.8414%Robert.Dalgleish@sk.sympatico.ca>

Craig Berry submitted half of this patch just yesterday.
Spooky cosmic resonance.

p4raw-id: //depot/perl@13291

ext/Socket/Socket.xs

index 4191097..fb60dc2 100644 (file)
@@ -222,7 +222,10 @@ inet_aton(host)
        {
        struct in_addr ip_address;
        struct hostent * phe;
-       int ok = inet_aton(host, &ip_address);
+       int ok =
+               (host != NULL) &&
+               (*host != '\0') &&
+               inet_aton(host, &ip_address);
 
        if (!ok && (phe = gethostbyname(host))) {
                Copy( phe->h_addr, &ip_address, phe->h_length, char );