Subject: bin/5166: newer (RIPE?) whois servers like -options passed to them
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mason@primenet.com.au>
List: netbsd-bugs
Date: 03/16/1998 13:25:44
>Number:         5166
>Category:       bin
>Synopsis:       newer (RIPE?) whois servers like -options passed to them
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Mar 16 05:35:00 1998
>Last-Modified:
>Originator:     Geoff C. Wing
>Organization:
Geoff Wing   <gcw@pobox.com>            Mobile : blown up, in for repairs
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/
>Release:        1.3 & -current
>Environment:
System: NetBSD coral.primenet.com.au 1.3 NetBSD 1.3 (CORAL) #0: Fri Jan 2 01:41:02 EST 1998 mason@coral.primenet.com.au:/home/src/netbsd/src/sys/arch/i386/compile/CORAL i386


>Description:
	Newer whois servers, probably based on the RIPE one, handle
	internally many different flags, eg.  -i, -m, -M, -a, etc.
	We should ignore any such options and pass them through.  The
	only one that we take notice of is   -h host  which must be the
	first option.  This means that we should avoid getopt since we
	can't know what options will be used nor what arguments they'll
	take as they're server parsed.
>How-To-Repeat:
	Obvious, I should think.
>Fix:
	
*** src/usr.bin/whois/whois.c.orig	Tue Oct 21 00:53:31 1997
--- src/usr.bin/whois/whois.c	Tue Mar 17 00:12:30 1998
***************
*** 78,97 ****
  	char *host;
  
  	host = NICHOST;
! 	while ((ch = getopt(argc, argv, "h:")) != -1)
! 		switch((char)ch) {
! 		case 'h':
! 			host = optarg;
! 			break;
! 		case '?':
! 		default:
! 			usage();
! 		}
! 	argc -= optind;
! 	argv += optind;
! 
! 	if (!argc)
  		usage();
  
  	hp = gethostbyname(host);
  	if (hp == NULL)
--- 78,94 ----
  	char *host;
  
  	host = NICHOST;
! 	if (!--argc)
  		usage();
+ 
+ 	/* "-h host", the only option, must be first.  Pass everything else */
+ 	if (!strcmp(*++argv, "-h")) {
+ 		argc -= 2;
+ 		if (argc <= 0)
+ 			usage();
+ 		host = *++argv;
+ 		argv++;
+ 	}
  
  	hp = gethostbyname(host);
  	if (hp == NULL)





>Audit-Trail:
>Unformatted: