From newton@gizmo.internode.com.au  Wed Oct  3 01:00:03 2001
Return-Path: <newton@gizmo.internode.com.au>
Received: from gizmo.internode.com.au (gizmo.internode.com.au [192.83.231.115])
	by hub.freebsd.org (Postfix) with ESMTP id B0ED437B403
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  3 Oct 2001 01:00:02 -0700 (PDT)
Received: (from newton@localhost)
	by gizmo.internode.com.au (8.11.0/8.9.3) id f937xVE22564;
	Wed, 3 Oct 2001 17:29:31 +0930 (CST)
	(envelope-from newton)
Message-Id: <200110030759.f937xVE22564@gizmo.internode.com.au>
Date: Wed, 3 Oct 2001 17:29:31 +0930 (CST)
From: newton@internode.com.au
Reply-To: newton@internode.com.au
To: FreeBSD-gnats-submit@freebsd.org, brawley@internode.com.au,
	justin@internode.com.au
Subject: whois gives contents of /etc/services for bad .biz lookups
X-Send-Pr-Version: 3.2

>Number:         31002
>Category:       bin
>Synopsis:       whois dumps contents of /etc/services when looking up non-existent .biz names
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    mike
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Oct 03 01:10:01 PDT 2001
>Closed-Date:    Thu Nov 15 20:57:23 PST 2001
>Last-Modified:  Thu Nov 15 21:10:01 PST 2001
>Originator:     Mark Newton
>Release:        FreeBSD 4.4-RELEASE
>Organization:
Internode Systems
>Environment:

	FreeBSD 4.4-RELEASE

>Description:

	Null-termination doesn't appear to be working correctly in
	whois.c:269 in a call to fgetln().  The returned buffer ends
	up containing the error message which tells you that whatever
	you're looking for doesn't exist, followed by most of the contents
	of /etc/services.

	The basic problem appear to be that the .biz whois server is
	returning non-standard information (or, at least, information in
	a non-standard format), which is defeating the efforts of 
	whois.c line 270 and 271 to null-terminate the buffer returned
	by fgetln().

>How-To-Repeat:

	% whois bad-domain.biz

>Fix:

	In an ideal world, the .biz people would emit error messages in 
	the same format as everyone else.  Because the world is less than
	ideal, however, life kinda sucks a bit.

	There are several potential fixes.  Unconditionally null-terminating
	the buffer returned by fgetln() is one:  buf[len - 1] = '\0' should
	probably happen between line 269 and line 270, so that we have a 
	null-terminated buffer whether the parsing efforts at line 270 and
	271 work properly or not.  There are other equally defensive 
	possibilities.


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->analyzed 
State-Changed-By: roam 
State-Changed-When: Wed Oct 3 01:49:36 PDT 2001 
State-Changed-Why:  
This is the same problem as in PR bin/30968. 
The fix is indeed to null-terminate the read string, as done in 
the patches posted in the audit trail of bin/30968. 
I'll commit the second patch shortly, after it has been properly reviewed. 


Responsible-Changed-From-To: freebsd-bugs->roam 
Responsible-Changed-By: roam 
Responsible-Changed-When: Wed Oct 3 01:49:36 PDT 2001 
Responsible-Changed-Why:  
I'll take care of this problem and commit the necessary patches. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31002 
Responsible-Changed-From-To: roam->mike 
Responsible-Changed-By: roam 
Responsible-Changed-When: Mon Oct 8 04:26:28 PDT 2001 
Responsible-Changed-Why:  
Actually it is Mike Barcroft, the whois(1) maintainer, who came up 
with a better patch. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=30968 
Responsible-Changed-From-To: roam->mike 
Responsible-Changed-By: roam 
Responsible-Changed-When: Mon Oct 8 04:26:28 PDT 2001 
Responsible-Changed-Why:  
Mike Barcroft came up with a better patch. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31002 
State-Changed-From-To: analyzed->closed 
State-Changed-By: mike 
State-Changed-When: Thu Nov 15 20:57:23 PST 2001 
State-Changed-Why:  

Duplicate of PR/31002. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=31002 

From: Mike Barcroft <mike@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org
Cc: Mark Newton <newton@internode.com.au>
Subject: Re: bin/31002: whois dumps contents of /etc/services when looking up non-existent .biz names
Date: Fri, 16 Nov 2001 00:03:16 -0500

 mike@FreeBSD.org <mike@FreeBSD.org> writes:
 > Duplicate of PR/31002.
 
 Sorry, that should say: Duplicate of PR bin/30928.
 
 Best regards,
 Mike Barcroft
>Unformatted:
