From andre.albsmeier@mchp.siemens.de  Mon Sep 16 05:22:11 2002
Return-Path: <andre.albsmeier@mchp.siemens.de>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D729537B400
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 16 Sep 2002 05:22:11 -0700 (PDT)
Received: from thoth.sbs.de (thoth.sbs.de [192.35.17.2])
	by mx1.FreeBSD.org (Postfix) with ESMTP id A184B43E4A
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 16 Sep 2002 05:22:10 -0700 (PDT)
	(envelope-from andre.albsmeier@mchp.siemens.de)
Received: from mail3.siemens.de (mail3.siemens.de [139.25.208.14])
	by thoth.sbs.de (8.11.6/8.11.6) with ESMTP id g8GCM3d06994
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 16 Sep 2002 14:22:04 +0200 (MEST)
Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.42.7])
	by mail3.siemens.de (8.11.6/8.11.6) with ESMTP id g8GCM3407849
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 16 Sep 2002 14:22:03 +0200 (MEST)
Received: (from localhost)
	by curry.mchp.siemens.de (8.12.5/8.12.5) id g8GCM3t7034049
	for FreeBSD-gnats-submit@freebsd.org; Mon, 16 Sep 2002 14:22:03 +0200 (CEST)
Message-Id: <200209161222.g8GCM241002371@curry.mchp.siemens.de>
Date: Mon, 16 Sep 2002 14:22:02 +0200 (CEST)
From: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] for whois to find APNIC hosts again
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         42834
>Category:       bin
>Synopsis:       [PATCH] for whois to find APNIC hosts again
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    mike
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 16 05:30:01 PDT 2002
>Closed-Date:    Tue Sep 24 10:31:30 PDT 2002
>Last-Modified:  Tue Sep 24 10:31:30 PDT 2002
>Originator:     Andre Albsmeier
>Release:        FreeBSD 4.7-PRERELEASE i386
>Organization:
>Environment:

System: FreeBSD 4.7-PRERELEASE #1: Mon Sep 16 10:39:46 CEST 2002

>Description:

When doing a "whois IP-Address" the various whois servers should be
queried recursively for an answer. This is done by matching the
answer of a query to whois.arin.net (ANICHOST) against specific
keywords defined in { RNICHOST, PNICHOST, BNICHOST, NULL } to find
the next server for querying.
This doesn't work for PNICHOST anymore since PNICHOST is defined
with lowercase letters but the answer of whois.arin.net contains
uppercase letters:

% whois 211.172.193.100
...
Comment:    This IP address range is not registered in the ARIN database.
            For details, refer to the APNIC Whois Database via
            WHOIS.APNIC.NET or http://www.apnic.net/apnic-bin/whois2.pl
            ^^^^^^^^^^^^^^^
            ** IMPORTANT NOTE: APNIC is the Regional Internet Registry
            for the Asia Pacific region. APNIC does not operate networks
...


>How-To-Repeat:

whois 211.172.193.100

>Fix:

Ignore the case when matching the keywords. To see if it works, I use
the patch below. A nicer solution would be to create a new library
function: char *strncasestr(const char *big, const char *little, size_t len);
and use this one :-)

The patch converts the contents of the received buffer into lowercase
letters befor performing the match. This has no sideeffects since the
buffer is not used anymore:

--- usr.bin/whois/whois.c.ORI	Mon Feb 18 08:42:29 2002
+++ usr.bin/whois/whois.c	Mon Sep 16 14:04:15 2002
@@ -287,6 +287,8 @@
 				s_asprintf(&nhost, "%.*s",
 				     (int)(buf + len - host), host);
 			} else if (strcmp(hostname, ANICHOST) == 0) {
+				for (i = 0; i <= (int)len; i++)
+					buf[i] = tolower(buf[i]);
 				for (i = 0; ip_whois[i] != NULL; i++) {
 					if (strnstr(buf, ip_whois[i], len) !=
 					    NULL) {


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->mike 
Responsible-Changed-By: mike 
Responsible-Changed-When: Wed Sep 18 00:37:16 PDT 2002 
Responsible-Changed-Why:  

Over to me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42834 

From: Andre Albsmeier <andre.albsmeier@mchp.siemens.de>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: bin/42834: [PATCH] for whois to find APNIC hosts again
Date: Tue, 24 Sep 2002 11:25:41 +0200

 This PR can be closed.
State-Changed-From-To: open->closed 
State-Changed-By: mike 
State-Changed-When: Tue Sep 24 10:31:05 PDT 2002 
State-Changed-Why:  

Fixed in -current and -stable. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=42834 
>Unformatted:
