From fanf@dotat.at  Mon Sep 10 16:42:34 2001
Return-Path: <fanf@dotat.at>
Received: from hand.dotat.at (host217-35-25-194.in-addr.btopenworld.com [217.35.25.194])
	by hub.freebsd.org (Postfix) with ESMTP id 079F637B405
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 10 Sep 2001 16:42:34 -0700 (PDT)
Received: from fanf by hand.dotat.at with local (Exim 3.33 #16)
	id 15gbd3-0000m6-00
	for FreeBSD-gnats-submit@freebsd.org; Tue, 11 Sep 2001 00:42:17 +0000
Message-Id: <E15gbd3-0000m6-00@hand.dotat.at>
Date: Tue, 11 Sep 2001 00:42:17 +0000
From: Tony Finch <dot@dotat.at>
Reply-To: Tony Finch <dot@dotat.at>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: `host` does not work properly with top-level domains
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         30496
>Category:       bin
>Synopsis:       `host` does not work properly with top-level domains
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Sep 10 16:50:01 PDT 2001
>Closed-Date:    Tue May 14 16:08:16 PDT 2002
>Last-Modified:  Tue May 14 16:08:16 PDT 2002
>Originator:     Tony Finch
>Release:        FreeBSD 4.4-RC i386
>Organization:
dotat labs
>Environment:
System: FreeBSD hand.dotat.at 4.4-RC FreeBSD 4.4-RC #4: Sat Sep 1 19:06:27 GMT 2001 fanf@hand.dotat.at:/FreeBSD/obj/FreeBSD/releng4/sys/SHARP i386

>Description:

`host` fails to make queries for top-level domains properly, because it
adds a superfluous dot to the end of the domain name when constructing
the query.

>How-To-Repeat:

fanf@hand.dotat.at:/FreeBSD/releng4/contrib/bind/bin/host
:; cat /etc/resolv.conf
search lab.dotat.at. dotat.at. .
nameserver 127.0.0.1
fanf@hand.dotat.at:~
:; /usr/obj/FreeBSD/releng4/usr.bin/host/host -d -v -t soa uk
Trying domain "lab.dotat.at."
;; res_nmkquery(QUERY, uk.lab.dotat.at., IN, SOA)
;; res_send()
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31536
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;;      uk.lab.dotat.at, type = SOA, class = IN
;; Querying server (# 1) address = 127.0.0.1
;; new DG socket
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 31536
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;;      uk.lab.dotat.at, type = SOA, class = IN
lab.dotat.at.           1H IN SOA       hand.dotat.at. dot.dotat.at. (
                                        999950951       ; serial
                                        1D              ; refresh
                                        5M              ; retry
                                        1W              ; expiry
                                        1H )            ; minimum
rcode = 3 (Non-existent domain), ancount=0
Trying domain "dotat.at."
;; res_nmkquery(QUERY, uk.dotat.at., IN, SOA)
;; res_send()
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31537
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;;      uk.dotat.at, type = SOA, class = IN
;; Querying server (# 1) address = 127.0.0.1
;; new DG socket
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 31537
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;;      uk.dotat.at, type = SOA, class = IN
dotat.at.               1H IN SOA       chiark.greenend.org.uk. dot.dotat.at. (
                                        999303549       ; serial
                                        1D              ; refresh
                                        5M              ; retry
                                        1W              ; expiry
                                        1H )            ; minimum
rcode = 3 (Non-existent domain), ancount=0
Trying domain "."
;; res_nmkquery(QUERY, uk.., IN, SOA)
res_nmkquery failed
No recovery, Host not found.
fanf@hand.dotat.at:~
:;

>Fix:

Index: host.c
===================================================================
RCS file: /home/ncvs/src/contrib/bind/bin/host/host.c,v
retrieving revision 1.1.1.2.2.4
diff -u -r1.1.1.2.2.4 host.c
--- host.c	2001/08/05 16:02:05	1.1.1.2.2.4
+++ host.c	2001/09/03 00:07:04
@@ -611,7 +611,8 @@
 	int n;
 	char host[NS_MAXDNAME];
 
-	if (domain == NULL)
+	if (domain == NULL ||
+	    domain[0] == '.' && domain[1] == '\0')
 		sprintf(host, "%.*s", NS_MAXDNAME, name);
 	else
 		sprintf(host, "%.*s.%.*s",
>Release-Note:
>Audit-Trail:

From: Kris Kennaway <kris@obsecurity.org>
To: Tony Finch <dot@dotat.at>
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: bin/30496: `host` does not work properly with top-level domains
Date: Mon, 10 Sep 2001 22:50:48 -0700

 --1yeeQ81UyVL57Vl7
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 > `host` fails to make queries for top-level domains properly, because it
 > adds a superfluous dot to the end of the domain name when constructing
 > the query.
 
 Isn't this a bug native to the vendor release?  If so, it should be
 taken up with them.
 
 Kris
 
 --1yeeQ81UyVL57Vl7
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.0.6 (FreeBSD)
 Comment: For info see http://www.gnupg.org
 
 iD8DBQE7naY4Wry0BWjoQKURAu9gAKC2ChF9hJdvn6rp4upuh+VAORPFsgCfYnWe
 lYSqPKfDe2t6h28sSdhRwlY=
 =KhsX
 -----END PGP SIGNATURE-----
 
 --1yeeQ81UyVL57Vl7--
State-Changed-From-To: open->closed 
State-Changed-By: fanf 
State-Changed-When: Tue May 14 16:07:42 PDT 2002 
State-Changed-Why:  
Fixed by bind-8.3.1. 

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