From xaa@xaa.xaa.iaehv.nl  Mon Nov 17 14:19:58 1997
Received: from alterego.xaa.iaehv.nl (alterego.xaa.IAEhv.nl [194.151.75.9])
          by hub.freebsd.org (8.8.7/8.8.7) with ESMTP id OAA20112
          for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Nov 1997 14:19:51 -0800 (PST)
          (envelope-from xaa@xaa.xaa.iaehv.nl)
Received: from xaa.xaa.iaehv.nl (xaa.xaa.iaehv.nl [194.151.75.10])
	by alterego.xaa.iaehv.nl (8.8.7/8.8.7) with ESMTP id XAA15804
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 17 Nov 1997 23:19:33 +0100 (MET)
	(envelope-from xaa@xaa.xaa.iaehv.nl)
Received: (from xaa@localhost) by xaa.xaa.iaehv.nl (8.8.8/8.8.2) id XAA06205; Mon, 17 Nov 1997 23:19:42 +0100 (MET)
Message-Id: <199711172219.XAA06205@xaa.xaa.iaehv.nl>
Date: Mon, 17 Nov 1997 23:19:42 +0100 (MET)
From: xaa@stack.nl
Reply-To: xaa@stack.nl
To: FreeBSD-gnats-submit@freebsd.org
Subject: 'host -t mx' coredumps
X-Send-Pr-Version: 3.2

>Number:         5073
>Category:       bin
>Synopsis:       'host -t mx' coredumps
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 17 14:20:00 PST 1997
>Closed-Date:    Tue Aug 4 03:02:17 PDT 1998
>Last-Modified:  Tue Aug  4 03:03:38 PDT 1998
>Originator:     Mark Huizer
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
>Environment:

	Tested on FreeBSD 2.2.stable, current, 2.1.5-alike

>Description:

	host -t mx should report a missing argument, but instead
	coredumps (sigsegv)

>How-To-Repeat:

	host -t mx

>Fix:
	
	probably check the source for some forgotten check or whatever

>Release-Note:
>Audit-Trail:

From: Sean Eric Fagan <sef@kithrup.com>
To: freebsd-gnats-submit@freebsd.org
Cc:  Subject: Re: bin/5073
Date: Mon, 17 Nov 1997 18:10:33 -0800 (PST)

 This patch should fix it; I've submitted it to Paul Vixie, so hopefully
 it'll be incorporated.
 
 Remember, kids:  getopt(3) is your friend.
 
 Index: host.c
 ===================================================================
 RCS file: /usr/cvs/src/contrib/bind/tools/host.c,v
 retrieving revision 1.1.1.1.2.1
 diff -u -r1.1.1.1.2.1 host.c
 --- host.c	1997/06/28 07:36:45	1.1.1.1.2.1
 +++ host.c	1997/11/18 01:59:45
 @@ -79,6 +79,7 @@
  #include <arpa/nameser.h>
  
  #include <stdio.h>
 +#include <stdlib.h>
  #include <netdb.h>
  #include <resolv.h>
  #include <ctype.h>
 @@ -135,63 +136,52 @@
  	register waitmode = 0;
  	char *oldcname;
  	int ncnames;
 +	int o;
  
  	res_init();
  	_res.retrans = 5;
  
 -	if (c < 2) {
 -		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 fo r 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 ((o = getopt(c, v, "wvrdt:c:a")) != EOF) {
 +	  switch (o) {
 +	  default:
 +	    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 infor"
 +		    "mation\n  -c class to look for non-Internet data\n  "
 +		    "-a is equivalent to '-v -t *'\n");
 +	    exit(1);
 +	  case 'w':
 +	    _res.retry = 1; _res.retrans = 15;
 +	    waitmode = 1;
 +	    break;
 +	  case 'r':
 +	    _res.options &= ~RES_RECURSE;
 +	    break;
 +	  case 'd':
 +	    _res.options |= RES_DEBUG;
 +	    break;
 +	  case 'v':
 +	    verbose = 1;
 +	    break;
 +	  case 'l':
 +	    list = 1;
 +	    break ;
 +	  case 't':
 +	    gettype = parsetype(optarg);
 +	    break;
 +	  case 'c':
 +	    getclass = parseclass(optarg);
 +	    break;
 +	  case 'a':
 +	    verbose = 1;
 +	    gettype = T_ANY;
 +	    break;
 +	  }
  	}
 -	while (c > 2 && v[1][0] == '-') {
 -		if (strcmp (v[1], "-w") == 0) {
 -			_res.retry = 1;
 -			_res.retrans = 15;
 -			waitmode = 1;
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-r") == 0) {
 -			_res.options &= ~RES_RECURSE;
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-d") == 0) {
 -			_res.options |= RES_DEBUG;
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-v") == 0) {
 -			verbose = 1;
 -			v++;
 -			c--;
 -		}
 -		else if (strcmp (v[1], "-l") == 0) {
 -			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) {
 -			verbose = 1;
 -			gettype = T_ANY;
 -			v++;
 -			c--;
 -		}		
 -        }
 +	c -= optind;
 +	v += optind;
  	if (c > 2) {
  		s = v[2];
  		server_specified++;

From: Bill Fenner <fenner@parc.xerox.com>
To: Sean Eric Fagan <sef@kithrup.com>
Cc: freebsd-gnats-submit@hub.freebsd.org
Subject: Re: bin/5073 
Date: Tue, 18 Nov 1997 10:03:46 PST

 Sean Eric Fagan <sef@kithrup.com> wrote:
 > Remember, kids:  getopt(3) is your friend.
 
 Remember also, kids, POSIX says that getopt(3) returns -1, not EOF.
 
 BUGS
      The getopt() function was once specified to return EOF instead of -1.
      This was changed by IEEE Std1003.2-1992 (``POSIX.2'') to decouple
      getopt() from <stdio.h>.
 
 
   Bill
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Tue Aug 4 03:02:17 PDT 1998 
State-Changed-Why:  
As part of our PR auditing campaign, this PR has been closed. 

Hopefully we will see this fix in one of the next revisions of bind. 

Sorry about the late reaction to this PR. 
>Unformatted:
