change inet_addr to inet_aton

The former cannot differentiate between errors (-1) and 255.255.255.255.
Switch to inet_aton which does not have this problem.
This commit is contained in:
Mike Frysinger 2018-01-11 03:32:05 +00:00
parent c037092c97
commit 5236e1513f
1 changed files with 3 additions and 3 deletions

View File

@ -352,6 +352,7 @@ HINF * gethostpoop (name, numeric)
struct in_addr iaddr;
register HINF * poop = NULL;
register int x;
int rc;
/* I really want to strangle the twit who dreamed up all these sockaddr and
hostent abstractions, and then forced them all to be incompatible with
@ -379,10 +380,9 @@ HINF * gethostpoop (name, numeric)
if (! poop)
bail ("gethostpoop fuxored");
strcpy (poop->name, unknown); /* preload it */
/* see wzv:workarounds.c for dg/ux return-a-struct inet_addr lossage */
iaddr.s_addr = inet_addr (name);
rc = inet_aton (name, &iaddr);
if (iaddr.s_addr == INADDR_NONE) { /* here's the great split: names... */
if (rc == 0) { /* here's the great split: names... */
if (numeric)
bail ("Can't parse %s as an IP address", name);
hostent = gethostbyname (name);