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