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
[EMAIL PROTECTED] | General Geek 
           CTHULU for President - Why choose the lesser of two evils?

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to