Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 27 Oct 2002 14:21:12 -0600
From:      GB Clark <gclarkii@vsservices.com>
To:        hackers@freebsd.org
Subject:   Fw: Anyone got time for a quick fix commit in the libc/db? Patch included
Message-ID:  <20021027142112.1d774e2c.gclarkii@vsservices.com>

next in thread | raw e-mail | index | archive | help
Hello,

There are two seperate bugs in libc/db.

The first is the in libc/db/hash/hash.c in hash_action.  If hash_action is called with HASH_DELETE and
the key is not found it will return -1 (error) instead of 1 (key not found) as documented in the man
page.
This bug is mentioned in PR misc/42429.

The second is in libc/db/hash/ndbm.c.  dbm_delete needs to be changed to return the status from
the db call directly.  As it stands now it just checks for a non-zero and returns -1 if this is so.
If it returned the status directly then it would work as documented.
This is the bug mentioned in PR misc/42422.

Attached are two patch files relative to lib/libc/db/hash.
Should have done more research before I sent the first PR...:)

GB
-PATCH1-
*** 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);

-PATCH2-
*** ndbm.c	Wed Sep  4 17:14:44 2002
--- ndbm.c.patched	Wed Sep  4 17:15:06 2002
***************
*** 171,181 ****
  
  	dbtkey.data = key.dptr;
  	dbtkey.size = key.dsize;
! 	status = (db->del)(db, &dbtkey, 0);
! 	if (status)
! 		return (-1);
! 	else
! 		return (0);
  }
  
  /*
--- 171,178 ----
  
  	dbtkey.data = key.dptr;
  	dbtkey.size = key.dsize;
! 	return (db->del)(db, &dbtkey, 0);
! 
  }
  
  /*
-CUT-

GB

-- 
GB Clark II             | Roaming FreeBSD Admin
gclarkii@VSServices.COM | General Geek 
           CTHULU for President - Why choose the lesser of two evils?

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021027142112.1d774e2c.gclarkii>