From root@ikabod.private  Sun Jan 28 16:28:19 2001
Return-Path: <root@ikabod.private>
Received: from ikabod.private (HSE-London-ppp208869.sympatico.ca [64.228.135.232])
	by hub.freebsd.org (Postfix) with ESMTP id B56BE37B6A0
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 28 Jan 2001 16:28:17 -0800 (PST)
Received: (from root@localhost)
	by ikabod.private (8.11.1/8.11.2) id f0T0SBR60587;
	Mon, 29 Jan 2001 00:28:11 GMT
	(envelope-from root)
Message-Id: <200101290028.f0T0SBR60587@ikabod.private>
Date: Mon, 29 Jan 2001 00:28:11 GMT
From: Mike Barcroft <mike@q9media.com>
Reply-To: Mike Barcroft <mike@q9media.com>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] Whois IP Address Handling
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         24707
>Category:       bin
>Synopsis:       [patch] Whois IP Address Handling
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Jan 28 16:30:01 PST 2001
>Closed-Date:    Mon May 28 14:37:34 PDT 2001
>Last-Modified:  Mon May 28 14:37:52 PDT 2001
>Originator:     Mike Barcroft
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
Q9 Media
>Environment:

$FreeBSD: src/usr.bin/whois/whois.c,v 1.16 2000/07/07 07:52:21 kris Exp $
$FreeBSD: src/usr.bin/whois/whois.1,v 1.16 2000/11/20 19:21:19 ru Exp $

>Description:

	If a host is not specified and the user enters a query of 
	an IP address, query whois.arin.net instead of returning:
	whois: 0.whois-servers.net: No Address associated with hostname

>How-To-Repeat:

	Apply patches below.

>Fix:

--- whois.c.orig	Fri Jul  7 07:52:21 2000
+++ whois.c	Sun Jan 28 19:08:14 2001
@@ -49,6 +49,7 @@
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#include <ctype.h>
 #include <err.h>
 #include <netdb.h>
 #include <stdio.h>
@@ -166,13 +167,19 @@
 				}
 			}
 			if (j != 0) {
-				qnichost = (char *) calloc(i - j + 1 +
-				    strlen(QNICHOST_TAIL), sizeof(char));
-				if (!qnichost) {
-					err(1, "calloc");
+				if (isdigit(*(*argv + j + 1))) {
+					(void) asprintf(&qnichost, "%s",
+					    ANICHOST);
+				} else {
+					qnichost = (char *) calloc(i - j
+					    + 1 + strlen(QNICHOST_TAIL),
+					    sizeof(char));
+					if (!qnichost) {
+						err(1, "calloc");
+					}
+					strcpy(qnichost, *argv + j + 1);
+					strcat(qnichost, QNICHOST_TAIL);
 				}
-				strcpy(qnichost, *argv + j + 1);
-				strcat(qnichost, QNICHOST_TAIL);
 
 				memset(&hints, 0, sizeof(hints));
 				hints.ai_flags = 0;

--- whois.1.orig	Mon Jan 29 00:06:42 2001
+++ whois.1	Mon Jan 29 00:12:55 2001
@@ -81,7 +81,10 @@
 .Pq Tn TLD
 of the supplied (single) argument, and appending ".whois-servers.net".
 This effectively allows a suitable whois server to be selected
-automatically for a large number of TLDs.
+automatically for a large number of TLDs.  In the event that an IP
+address is specified, the whois server will default to the American
+Registry for Internet Numbers
+.Pq Tn ARIN .
 If no required whois-servers.net subdomain found, fallback
 to whois.crsnic.net provided.
 .It Fl i

>Release-Note:
>Audit-Trail:

From: Peter Pentchev <roam@orbitel.bg>
To: Mike Barcroft <mike@q9media.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/24707: [patch] Whois IP Address Handling
Date: Mon, 29 Jan 2001 11:24:39 +0200

 On Mon, Jan 29, 2001 at 12:28:11AM +0000, Mike Barcroft wrote:
 > 
 > >Number:         24707
 > >Category:       bin
 > >Synopsis:       [patch] Whois IP Address Handling
 > >Originator:     Mike Barcroft
 > >Organization:
 > Q9 Media
 > >Environment:
 > 
 > $FreeBSD: src/usr.bin/whois/whois.c,v 1.16 2000/07/07 07:52:21 kris Exp $
 > $FreeBSD: src/usr.bin/whois/whois.1,v 1.16 2000/11/20 19:21:19 ru Exp $
 > 
 > >Description:
 > 
 > 	If a host is not specified and the user enters a query of 
 > 	an IP address, query whois.arin.net instead of returning:
 > 	whois: 0.whois-servers.net: No Address associated with hostname
 > 
 > >How-To-Repeat:
 > 
 > 	Apply patches below.
 > 
 > >Fix:
 > 
 > --- whois.c.orig	Fri Jul  7 07:52:21 2000
 > +++ whois.c	Sun Jan 28 19:08:14 2001
 > @@ -49,6 +49,7 @@
 >  #include <sys/socket.h>
 >  #include <netinet/in.h>
 >  #include <arpa/inet.h>
 > +#include <ctype.h>
 >  #include <err.h>
 >  #include <netdb.h>
 >  #include <stdio.h>
 > @@ -166,13 +167,19 @@
 >  				}
 >  			}
 >  			if (j != 0) {
 > -				qnichost = (char *) calloc(i - j + 1 +
 > -				    strlen(QNICHOST_TAIL), sizeof(char));
 > -				if (!qnichost) {
 > -					err(1, "calloc");
 > +				if (isdigit(*(*argv + j + 1))) {
 
 Just a little comment - I think in checking for dotted-quad IP addresses
 you should be doing just that - check for dotted quads, not just check
 for a starting digit.  Yes, I know that the RFC's forbid - or at least
 express a mild disagreement - with labels starting with a digit, but
 in the real world, your patch would break e.g. 'whois 42.com' :(
 
 G'luck,
 Peter
 
 -- 
 I had to translate this sentence into English because I could not read the original Sanskrit.
 

From: Mike Barcroft <mike@coffee.q9media.com>
To: Peter Pentchev <roam@orbitel.bg>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/24707: [patch] Whois IP Address Handling
Date: Mon, 29 Jan 2001 11:31:26 -0500 (EST)

 > Just a little comment - I think in checking for dotted-quad IP addresses
 > you should be doing just that - check for dotted quads, not just check
 > for a starting digit.  Yes, I know that the RFC's forbid - or at least
 > express a mild disagreement - with labels starting with a digit, but
 > in the real world, your patch would break e.g. 'whois 42.com' :(
 
 Not true.  The patch checks the TLD, so 42.com works and 10.0.0.0 goes to
 ARIN.  Since a TLD is never going to be a digit, it's safe to assume that
 it's an IP address.
 
 Best regards,
 Mike Barcroft
 

From: Peter Pentchev <roam@orbitel.bg>
To: Mike Barcroft <mike@coffee.q9media.com>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/24707: [patch] Whois IP Address Handling
Date: Tue, 30 Jan 2001 10:24:55 +0200

 On Mon, Jan 29, 2001 at 11:31:26AM -0500, Mike Barcroft wrote:
 > 
 > > Just a little comment - I think in checking for dotted-quad IP addresses
 > > you should be doing just that - check for dotted quads, not just check
 > > for a starting digit.  Yes, I know that the RFC's forbid - or at least
 > > express a mild disagreement - with labels starting with a digit, but
 > > in the real world, your patch would break e.g. 'whois 42.com' :(
 > 
 > Not true.  The patch checks the TLD, so 42.com works and 10.0.0.0 goes to
 > ARIN.  Since a TLD is never going to be a digit, it's safe to assume that
 > it's an IP address.
 
 Oops.  You're right, sorry.  I promise I'll actually read the code
 next time :)
 
 G'luck,
 Peter
 
 -- 
 Do you think anybody has ever had *precisely this thought* before?
 

From: Josef Karthauser <joe@tao.org.uk>
To: Mike Barcroft <mike@q9media.com>
Cc: FreeBSD-gnats-submit@FreeBSD.org
Subject: Re: bin/24707: [patch] Whois IP Address Handling
Date: Fri, 2 Feb 2001 16:40:52 +0000

 --GRPZ8SYKNexpdSJ7
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Mon, Jan 29, 2001 at 12:28:11AM +0000, Mike Barcroft wrote:
 >=20
 > >Number:         24707
 > >Category:       bin
 > >Synopsis:       [patch] Whois IP Address Handling
 > >Confidential:   no
 > >Severity:       non-critical
 > >Priority:       low
 > >Responsible:    freebsd-bugs
 > >State:          open
 > >Quarter:       =20
 > >Keywords:      =20
 > >Date-Required:
 > >Class:          change-request
 > >Submitter-Id:   current-users
 > >Arrival-Date:   Sun Jan 28 16:30:01 PST 2001
 > >Closed-Date:
 > >Last-Modified:
 > >Originator:     Mike Barcroft
 > >Release:        FreeBSD 5.0-CURRENT i386
 > >Organization:
 > Q9 Media
 > >Environment:
 >=20
 > $FreeBSD: src/usr.bin/whois/whois.c,v 1.16 2000/07/07 07:52:21 kris Exp $
 > $FreeBSD: src/usr.bin/whois/whois.1,v 1.16 2000/11/20 19:21:19 ru Exp $
 >=20
 > >Description:
 >=20
 > 	If a host is not specified and the user enters a query of=20
 > 	an IP address, query whois.arin.net instead of returning:
 > 	whois: 0.whois-servers.net: No Address associated with hostname
 
 What does this do for European addresses?  Normally we'd use
 whois.ripe.net for these.  Is there anyway that you can modify this
 patch to get these referred?  If you can I'll definitely integrate it.
 
 Joe
 
 --GRPZ8SYKNexpdSJ7
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.4 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iEYEARECAAYFAjp64xQACgkQXVIcjOaxUBbQDACfQc27rXlOWAfV/kEAutpO1EWb
 Hr0AoMhY99HKqJJ97Lkss/3k0eZjh94O
 =CEv4
 -----END PGP SIGNATURE-----
 
 --GRPZ8SYKNexpdSJ7--
 
State-Changed-From-To: open->closed 
State-Changed-By: phk 
State-Changed-When: Mon May 28 14:37:34 PDT 2001 
State-Changed-Why:  
Committed with a fixed man-page patch.  Thanks! 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=24707 
>Unformatted:
 >System: FreeBSD 5.0-CURRENT
