From nobody@FreeBSD.org  Wed Sep  4 15:17:55 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 361F737B400
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  4 Sep 2002 15:17:55 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id EB38443E4A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  4 Sep 2002 15:17:54 -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 g84MHsOT099117
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 4 Sep 2002 15:17:54 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g84MHsBt099116;
	Wed, 4 Sep 2002 15:17:54 -0700 (PDT)
Message-Id: <200209042217.g84MHsBt099116@www.freebsd.org>
Date: Wed, 4 Sep 2002 15:17:54 -0700 (PDT)
From: GB Clark <gclarkii@vsservices.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: hash_action called with HASH_DELETE does NOT return 1 if the key is not found
X-Send-Pr-Version: www-1.0

>Number:         42429
>Category:       kern
>Synopsis:       [libc] [patch] hash_action called with HASH_DELETE does NOT return 1 if the key is not found
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 04 15:20:01 PDT 2002
>Closed-Date:    
>Last-Modified:  Tue Oct 25 23:58:34 GMT 2005
>Originator:     GB Clark
>Release:        4.6-STABLE
>Organization:
VSS
>Environment:
FreeBSD prime.vsservices.com 4.6-STABLE FreeBSD 4.6-STABLE #0: Thu Aug 22 01:29:14 CDT 2002     gclarkii@prime.vsservices.com:/1002/objtree/usr/src/sys/PRIME  i386
>Description:
if hash_action in src/lib/libc/db/hash.c is called with HASH_DELETE, it will NOT return 1 if the key is not found as documented.
>How-To-Repeat:
call dbm_delete from ndbm with a non-exist key. it will return -1 instead of 1 as documented.
>Fix:
in hash_action if the key is not found, the default action is to return -1.  HASH_GET needs to be moved below HASH_DELETE and HASH_DELETE should return 1 instead of -1.
PR misc/42422 needs to be fixed also if dbm_delete is work properly.
Please see freebsd-hackers for email from me for the patches.
>Release-Note:
>Audit-Trail:

From: GB Clark <gclarkii@vsservices.com>
To: freebsd-gnats-submit@FreeBSD.org, gclarkii@vsservices.com
Cc:  
Subject: Re: misc/42429: hash_action called with HASH_DELETE does NOT return
 1 if the key is not found
Date: Thu, 09 Jan 2003 01:31:16 -0600

 This is a multi-part message in MIME format.
 --------------050205080802030702020100
 Content-Type: text/plain; charset=us-ascii; format=flowed
 Content-Transfer-Encoding: 7bit
 
 Hello,
 
 Attached is a patch to correct this bug.
 
 GB
 
 -- 
 GB Clark II             | Roaming FreeBSD Admin
 gclarkii@VSServices.COM | General Geek
             CTHULU for President - Why choose the lesser of two evils?
 
 --------------050205080802030702020100
 Content-Type: text/plain;
  name="db.patch.1.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline;
  filename="db.patch.1.txt"
 
 *** hash.c	Wed Sep  4 17:13:22 2002
 --- hash.c.patched	Wed Sep  4 17:11:03 2002
 ***************
 *** 685,692 ****
   			save_bufp->flags &= ~BUF_PIN;
   			return (SUCCESS);
   		}
 - 	case HASH_GET:
   	case HASH_DELETE:
   	default:
   		save_bufp->flags &= ~BUF_PIN;
   		return (ABNORMAL);
 --- 685,693 ----
   			save_bufp->flags &= ~BUF_PIN;
   			return (SUCCESS);
   		}
   	case HASH_DELETE:
 + 		return 1;
 + 	case HASH_GET:
   	default:
   		save_bufp->flags &= ~BUF_PIN;
   		return (ABNORMAL);
 
 --------------050205080802030702020100--
 
>Unformatted:
