From 5236e1513f9c405ef4b95ecd0025885ed47ba104 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 11 Jan 2018 03:32:05 +0000 Subject: [PATCH] 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. --- netcat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netcat.c b/netcat.c index 562791d..6b83d8e 100644 --- a/netcat.c +++ b/netcat.c @@ -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);