Subject: bin/3468: ping -n calls gethostbyaddr()
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jtp@iki.fi>
List: netbsd-bugs
Date: 04/09/1997 16:48:10
>Number:         3468
>Category:       bin
>Synopsis:       ping -n calls gethostbyaddr()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr  9 07:05:01 1997
>Last-Modified:
>Originator:     Jukka Partanen
>Organization:
	None
>Release:        April 7, 1997
>Environment:
System: NetBSD awreety.research.nokia.com 1.2D NetBSD 1.2D (AWREETY) #1: Mon Apr 7 10:03:02 EEST 1997 partanen@awreety.research.nokia.com:/usr/src/current/src/sys/arch/i386/compile/AWREETY i386


>Description:
	Using ping with -n calls gethostbyaddr() resulting in a DNS query 
	which may take a while to timeout. According to ping(8) this should
	not happen.

>How-To-Repeat:
	ping -n 1.2.3.4

>Fix:
--- ping.c.orig	Mon Mar 24 14:16:55 1997
+++ ping.c	Wed Apr  9 16:41:27 1997
@@ -1603,8 +1603,11 @@
     if (inet_aton(name, &sa->sin_addr) != 0) {
 	    if (realname == NULL)
 		return;
-	    hp = gethostbyaddr((char *) &sa->sin_addr, sizeof(sa->sin_addr), 
-		AF_INET);
+	    if ((pingflags & F_NUMERIC) != 0)
+		hp = NULL;
+	    else
+		hp = gethostbyaddr((char *) &sa->sin_addr,
+				   sizeof(sa->sin_addr), AF_INET);
 	    if (hp == NULL)
 		(void) strncpy(realname, name, MAXHOSTNAMELEN);
 	    else


>Audit-Trail:
>Unformatted: