Bug 24707

Summary: [patch] Whois IP Address Handling
Product: Base System Reporter: mike <mike>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff
none
file.diff none

Description mike 2001-01-29 00:30:01 UTC
	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.
Comment 1 Peter Pentchev 2001-01-29 09:24:39 UTC
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.
Comment 2 mike 2001-01-29 16:31:26 UTC
> 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
Comment 3 Peter Pentchev 2001-01-30 08:24:55 UTC
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?
Comment 4 Josef Karthauser 2001-02-02 16:40:52 UTC
On Mon, Jan 29, 2001 at 12:28:11AM +0000, Mike Barcroft wrote:
> 
> >Number:         24707
> >Category:       bin
> >Synopsis:       [patch] Whois IP Address Handling
> >Confidential:   no
> >Severity:       non-critical
> >Priority:       low
> >Responsible:    freebsd-bugs
> >State:          open
> >Quarter:        
> >Keywords:       
> >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:
> 
> $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


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
Comment 5 Poul-Henning Kamp freebsd_committer freebsd_triage 2001-05-28 22:37:34 UTC
State Changed
From-To: open->closed

Committed with a fixed man-page patch.  Thanks!