NetBSD Problem Report #46035

From apb@cequrux.com  Fri Feb 17 08:24:12 2012
Return-Path: <apb@cequrux.com>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	by www.NetBSD.org (Postfix) with ESMTP id DB10663D712
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 17 Feb 2012 08:24:12 +0000 (UTC)
Message-Id: <20120217082405.8D0C02C5DFB7@apb-laptoy.apb.alt.za>
Date: Fri, 17 Feb 2012 08:24:05 +0000 (UTC)
From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@gnats.NetBSD.org
Subject: db(1) "-N" behaviour is reversed
X-Send-Pr-Version: 3.95

>Number:         46035
>Category:       bin
>Synopsis:       db(1) "-N" behaviour is reversed
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb 17 08:25:00 +0000 2012
>Closed-Date:    Thu Jan 03 23:41:18 +0000 2013
>Last-Modified:  Thu Jan 03 23:41:18 +0000 2013
>Originator:     Alan Barrett
>Release:        NetBSD 5.99.65
>Organization:
Not much
>Environment:
System: NetBSD 5.99.65 i386
>Description:
	The db(1) man page says

           -N          Do not include the NUL byte at the end of the key or
                       value.

	but the actual behaviour is the reverse: The last byte in
	the key or value is suppressed by default (whether or not
	the last byte is a NUL), and the "-N" flag causes the last
	byte to be included.
>How-To-Repeat:
	$ db -Sb -Ub -To -N hash /etc/pwd.db 'VERSION'
	db: Unknown key `VERSION'
	$ db -Sb -Ub -To -N hash /etc/pwd.db 'VERSION\0'
	VERSION\000     \001\000\000\000
	$ db -Sb -Ub -To hash /etc/pwd.db 'VERSION'
	VERSION \001\000\000
	$ db -Sb -Ub -To hash /etc/pwd.db 'VERSION\0'
	db: Unknown key `VERSION\0'

	Clearly, the invocations with "-N" are displaying an extra
	byte on output, and parsing an extra byte on input, which
	is the reverse of the documented behaviour.

	In the source code, there's a flag named F_NO_NUL, but its
	use is the reverse of its name.  When the flag is set, the
	extra byte is NOT removed, and when the flag is not set,
	the extra byte IS removed.

>Fix:
	Change the documentation to match the behaviour.

	Change the source code to use an F_INCLUDE_NUL flag instead
	of F_NO_NUL, leaving the externally observable behaviour
	unchanged, but fixing the inconsistency between the name
	and the meaning of the flag.

	Alternatively, change the behaviour to match the documentation,
	but this would be an incompatible change, and will break
	almost all users of db(1).

>Release-Note:

>Audit-Trail:
From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46035 CVS commit: src/usr.bin/db
Date: Fri, 17 Feb 2012 11:18:55 +0000

 Module Name:	src
 Committed By:	apb
 Date:		Fri Feb 17 11:18:55 UTC 2012

 Modified Files:
 	src/usr.bin/db: db.1

 Log Message:
 db(1) "-N" flag means "Include the NUL byte at the end of the key
 or value".  (Previously, the description was reversed.)  Also expand
 the description.

 This is the first half of a fix for PR 46035.


 To generate a diff of this commit:
 cvs rdiff -u -r1.25 -r1.26 src/usr.bin/db/db.1

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Alan Barrett" <apb@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/46035 CVS commit: src/usr.bin/db
Date: Fri, 17 Feb 2012 11:37:33 +0000

 Module Name:	src
 Committed By:	apb
 Date:		Fri Feb 17 11:37:33 UTC 2012

 Modified Files:
 	src/usr.bin/db: db.c

 Log Message:
 The "-N" command line option means "include the terminating NUL byte",
 so rename the corresponding flag from F_NO_NUL to F_INCLUDE_NUL to match
 the behaviour.

 This is the second half of the fix for PR 46035.


 To generate a diff of this commit:
 cvs rdiff -u -r1.25 -r1.26 src/usr.bin/db/db.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: PR/46035 CVS commit: src/usr.bin/db
Date: Sun, 22 Apr 2012 20:04:18 +0000

 On Fri, Feb 17, 2012 at 11:40:05AM +0000, Alan Barrett wrote:
  >  Module Name:	src
  >  Committed By:	apb
  >  Date:		Fri Feb 17 11:37:33 UTC 2012
  >  
  >  Modified Files:
  >  	src/usr.bin/db: db.c
  >  
  >  Log Message:
  >  The "-N" command line option means "include the terminating NUL byte",
  >  so rename the corresponding flag from F_NO_NUL to F_INCLUDE_NUL to match
  >  the behaviour.
  >  
  >  This is the second half of the fix for PR 46035.

 Should this (and the other half) be pulled up to -6, or can the PR be
 closed?

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Thu, 03 Jan 2013 23:41:18 +0000
State-Changed-Why:
fixed in HEAD - if anyone wants the fix in netbsd-6 let us know.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.