From chris@holly.dyndns.org Fri Mar 26 12:10:37 1999
Return-Path: <chris@holly.dyndns.org>
Received: from holly.dyndns.org (ip77.houston13.tx.pub-ip.psi.net [38.27.213.77])
	by hub.freebsd.org (Postfix) with ESMTP id 90AFC14ED9
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 26 Mar 1999 12:10:34 -0800 (PST)
	(envelope-from chris@holly.dyndns.org)
Received: (from chris@localhost)
	by holly.dyndns.org (8.9.3/8.9.3) id OAA05245;
	Fri, 26 Mar 1999 14:10:09 -0600 (CST)
	(envelope-from chris)
Message-Id: <199903262010.OAA05245@holly.dyndns.org>
Date: Fri, 26 Mar 1999 14:10:09 -0600 (CST)
From: Chris Costello <chris@holly.dyndns.org>
Reply-To: chris@calldei.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: host(1) is broken - multiple options in one arg (-vt) cause a loop of some sort
X-Send-Pr-Version: 3.2

>Number:         10807
>Category:       bin
>Synopsis:       host(1) is broken - multiple options in one arg (-vt) cause a loop of some sort
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Mar 26 12:20:00 PST 1999
>Closed-Date:    Sun Jan 30 12:52:20 PST 2000
>Last-Modified:  Sun Jan 30 12:53:01 PST 2000
>Originator:     Chris Costello
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
none
>Environment:

	FreeBSD 4.0-CURRENT, CVSupped March 25, 1999

>Description:

	host -vt hinfo somehost.somedomain nameserver causes host to seem
	to go into an infinite loop after calling issetugid() and this appears
	to have to do with the somewhat broken option parsing.

>How-To-Repeat:

	host -vt hinfo your.favorite.domain [your.nameserver]

>Fix:
	
--- host.c.orig	Fri Mar 26 13:54:17 1999
+++ host.c	Fri Mar 26 14:06:59 1999
@@ -168,7 +168,7 @@
 main(int c, char **v) {
 	struct in_addr addr;
 	struct hostent *hp;
-	char *s, *oldcname;
+	char *s, *oldcname, ch;
 	int inverse = 0, waitmode = 0;
 	int ncnames;
 
@@ -179,55 +179,38 @@
 		fprintf(stderr, "Usage: host [-w] [-v] [-r] [-d] [-t querytype] [-c class] [-a] host [server]\n  -w to wait forever until reply\n  -v for verbose output\n  -r to disable recursive processing\n  -d to turn on debugging output\n  -t querytype to look for a specific type of information\n  -c class to look for non-Internet data\n  -a is equivalent to '-v -t *'\n");
 		exit(1);
 	}
-	while (c > 2 && v[1][0] == '-') {
-		if (strcmp (v[1], "-w") == 0) {
+	while ((ch = getopt(c, v, "hwvrdlt:c:a")) != -1)
+		switch (ch) {
+		case 'w':	
 			_res.retry = 1;
 			_res.retrans = 15;
 			waitmode = 1;
-			v++;
-			c--;
-		}
-		else if (strcmp (v[1], "-r") == 0) {
+			break;
+		case 'r':
 			_res.options &= ~RES_RECURSE;
-			v++;
-			c--;
-		}
-		else if (strcmp (v[1], "-d") == 0) {
+			break;
+		case 'd':
 			_res.options |= RES_DEBUG;
-			v++;
-			c--;
-		}
-		else if (strcmp (v[1], "-v") == 0) {
+			break;
+		case 'v':
 			verbose = 1;
-			v++;
-			c--;
-		}
-		else if (strcmp (v[1], "-l") == 0) {
+			break;
+		case 'l':
 			list = 1;
-			v++;
-			c--;
-		}
-		else if (strncmp (v[1], "-t", 2) == 0) {
-			v++;
-			c--;
-			gettype = parsetype(v[1]);
-			v++;
-			c--;
-		}
-		else if (strncmp (v[1], "-c", 2) == 0) {
-			v++;
-			c--;
-			getclass = parseclass(v[1]);
-			v++;
-			c--;
-		}
-		else if (strcmp (v[1], "-a") == 0) {
+			break;
+		case 't':
+			gettype = parsetype(optarg);
+			break;
+		case 'c':
+			getclass = parseclass(optarg);
+			break;
+		case 'a':
 			verbose = 1;
 			gettype = ns_t_any;
-			v++;
-			c--;
+			break;
 		}		
-        }
+	c -= optind - 1;
+	v += optind - 1;	
 	if (c > 2) {
 		s = v[2];
 		server_specified++;

>Release-Note:
>Audit-Trail:

From: "Danny J. Zerkel" <dzerkel@columbus.rr.com>
To: freebsd-gnats-submit@FreeBSD.org, chris@calldei.com
Cc:  
Subject: Re: bin/10807: host(1) is broken - multiple options in one arg (-vt) 
 cause a loop of some sort
Date: Tue, 25 Jan 2000 23:23:41 -0500

 Fixed in current BIND.
 
 -- Danny J. Zerkel
 dzerkel@columbus.rr.com
 
 
 
State-Changed-From-To: open->closed 
State-Changed-By: chris 
State-Changed-When: Sun Jan 30 12:52:20 PST 2000 
State-Changed-Why:  
This PR is no longer applicable as the BIND update has brought a fix to this 
problem. 
>Unformatted:
