From fd76d3287f3e866b9892ff897340ba4b2b69651e Mon Sep 17 00:00:00 2001
From: deraadt <>
Date: Sat, 5 Jun 1999 19:33:49 +0000
Subject: buf oflow; and use inet_aton()

---
 src/usr.bin/nc/netcat.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

(limited to 'src')

diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c
index bb0b30749d..bad1676007 100644
--- a/src/usr.bin/nc/netcat.c
+++ b/src/usr.bin/nc/netcat.c
@@ -344,7 +344,7 @@ HINF * gethostpoop (name, numeric)
    Maybe that's why my C code reads like assembler half the time... */
 
 /* If we want to see all the DNS stuff, do the following hair --
-   if inet_addr, do reverse and forward with any warnings; otherwise try
+   if inet_aton, do reverse and forward with any warnings; otherwise try
    to do forward and reverse with any warnings.  In other words, as long
    as we're here, do a complete DNS check on these clowns.  Yes, it slows
    things down a bit for a first run, but once it's cached, who cares? */
@@ -355,11 +355,9 @@ HINF * gethostpoop (name, numeric)
     poop = (HINF *) Hmalloc (sizeof (HINF));
   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);
+  strlcpy (poop->name, unknown, sizeof(poop->name));	/* preload it */
+  if (inet_aton (name, &iaddr) == 0) { /* here's the great split: names... */
 
-  if (iaddr.s_addr == INADDR_NONE) {	/* here's the great split: names... */
     if (numeric)
       bail ("Can't parse %s as an IP address", name);
     hostent = gethostbyname (name);
-- 
cgit v1.2.3-55-g6feb