From 93b19fdf9a96b411515223da8919ec0f57ea7c96 Mon Sep 17 00:00:00 2001 From: Hallvard Furuseth Date: Thu, 5 Jun 2003 11:55:27 +0000 Subject: [PATCH] Fix bdb_db_hash() to handle padding bits in integers. --- servers/slapd/back-bdb/dbcache.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/servers/slapd/back-bdb/dbcache.c b/servers/slapd/back-bdb/dbcache.c index 7c99c19196..88647373e9 100644 --- a/servers/slapd/back-bdb/dbcache.c +++ b/servers/slapd/back-bdb/dbcache.c @@ -29,17 +29,13 @@ bdb_db_hash( u_int32_t length ) { - u_int32_t ret = 0; - unsigned char *dst = (unsigned char *)&ret; - const unsigned char *src = (const unsigned char *)bytes; + u_int32_t i, ret = 0; if ( length > sizeof(u_int32_t) ) length = sizeof(u_int32_t); - while ( length ) { - *dst++ = *src++; - length--; - } + for( i = 0; i < length; i++ ) + ret = (ret << 8) + ((const unsigned char *)bytes)[i]; return ret; } -- 2.39.5