[Date Prev][Date Next] [Chronological] [Thread] [Top]

RE: Patch: bdb_db_hash() problems (ITS#1726)

Interesting. You actually have a machine with 9-bit bytes or 36-bit ints?

Much of your if condition should be resolved at compile time by the
preprocessor, not at runtime. It may be simpler just to do the single-byte
copies and eliminate the conditions altogether. For 4 bytes, it's probably
cheaper than invoking memcpy anyway.

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc
  Symas: Premier OpenSource Development and Support

> -----Original Message-----
> From: owner-openldap-bugs@OpenLDAP.org
> [mailto:owner-openldap-bugs@OpenLDAP.org]On Behalf Of
> h.b.furuseth@usit.uio.no
> Sent: Thursday, April 04, 2002 1:09 AM
> To: openldap-its@OpenLDAP.org
> Subject: Patch: bdb_db_hash() problems (ITS#1726)
> Full_Name: Hallvard B. Furuseth
> Version: HEAD (2002-04-02)
> OS:
> URL: http://folk.uio.no/hbf/OpenLDAP/bdb_db_hash.txt
> Submission from: (NULL) (
> bdb_db_hash() has 3 problems:
> - it accesses the bytes argument as an u_int32_t*, even though I can
>   see no guarantee that bytes is aligned for integer access.
> - It expects a 4-byte value, but db->open() tests it with a string.
> - It can crash on hosts where integers have padding bits, since bad
>   values for padding bits can cause a crash.
> Here is a patch.  It removes the '#if LUTIL_HASH_BYTES' too, since if
> the #if fails it's still possible to use a simpler hash function than
> the one bdb provides.