From nobody@FreeBSD.org  Tue Aug  6 12:45:05 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 3ACC837B400
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  6 Aug 2002 12:45:05 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id F08EA43E65
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  6 Aug 2002 12:45:04 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g76JixOT054843
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 6 Aug 2002 12:44:59 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g76JixwE054842;
	Tue, 6 Aug 2002 12:44:59 -0700 (PDT)
Message-Id: <200208061944.g76JixwE054842@www.freebsd.org>
Date: Tue, 6 Aug 2002 12:44:59 -0700 (PDT)
From: TOGAWA Satoshi <toga@puyo.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: src/contrib/bind/bin/dig/dig.c has bug in reverse6()
X-Send-Pr-Version: www-1.0

>Number:         41388
>Category:       bin
>Synopsis:       src/contrib/bind/bin/dig/dig.c has bug in reverse6()
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    dougb
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 06 12:50:01 PDT 2002
>Closed-Date:    Sun Nov 17 01:46:46 PST 2002
>Last-Modified:  Sun Nov 17 01:46:46 PST 2002
>Originator:     TOGAWA Satoshi
>Release:        4-STABLE
>Organization:
>Environment:
FreeBSD mituki.vegalta.org 4.6-STABLE FreeBSD 4.6-STABLE #13: Thu Aug  1 15:18:22 JST 2002     togawa@mituki.vegalta.org:/usr/obj/usr/src/sys/MITUKI  i386

>Description:
src/contrib/bind/bin/dig/dig.c has bug in reverse6(),
so when we use option -x, we get wrong answer.

I think both -current and RELENG_4_6 have same problem.

>How-To-Repeat:
For example:

---
$ dig -x 3ffe:505:2054::1

; <<>> DiG 8.3 <<>> -x 
;; res options: init recurs defnam dnsrch
;; got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 2
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUERY SECTION:
;;      1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.5.0.2.0.0.5.0.e.f.f.3.ip6.arpa, type = ANY, class = IN

25th dotted letter, must be "5", is wrong "0".

>Fix:
--- dig.c.orig	Wed Aug  7 04:28:59 2002
+++ dig.c	Wed Aug  7 04:29:04 2002
@@ -1799,7 +1799,7 @@
 		in6->s6_addr[6] & 0x0f, (in6->s6_addr[6] >> 4) & 0x0f,
 		in6->s6_addr[5] & 0x0f, (in6->s6_addr[5] >> 4) & 0x0f,
 		in6->s6_addr[4] & 0x0f, (in6->s6_addr[4] >> 4) & 0x0f,
-		in6->s6_addr[6] & 0x0f, (in6->s6_addr[3] >> 4) & 0x0f,
+		in6->s6_addr[3] & 0x0f, (in6->s6_addr[3] >> 4) & 0x0f,
 		in6->s6_addr[2] & 0x0f, (in6->s6_addr[2] >> 4) & 0x0f,
 		in6->s6_addr[1] & 0x0f, (in6->s6_addr[1] >> 4) & 0x0f,
 		in6->s6_addr[0] & 0x0f, (in6->s6_addr[0] >> 4) & 0x0f);

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->dougb 
Responsible-Changed-By: dougb 
Responsible-Changed-When: Sun Nov 3 20:33:06 PST 2002 
Responsible-Changed-Why:  

I'll ask the bind maintainers about this one, but the patch 
looks right to me. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41388 
State-Changed-From-To: open->feedback 
State-Changed-By: dougb 
State-Changed-When: Sun Nov 3 21:51:07 PST 2002 
State-Changed-Why:  

The bug is confirmed. However, this is contrib code, and that  
file is still on the vendor branch. Since this bug will not affect 
that many users, do you think you could live with handling the 
fix locally until we import the next version from the vendor? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=41388 
State-Changed-From-To: feedback->closed 
State-Changed-By: dougb 
State-Changed-When: Sun Nov 17 01:45:24 PST 2002 
State-Changed-Why:  

Feedback timeout. I've committed a patch to the BIND 8.3.4 
port that should make it easier for you to deal with this 
problem locally until they release a new version. Take a 
look at the PORT_REPLACES_BASE_BIND8 option in the Makefile. 

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