Fix bdb_db_hash() to handle padding bits in integers.

This commit is contained in:
Hallvard Furuseth 2003-06-05 11:55:27 +00:00
parent 6fab51e339
commit 93b19fdf9a

View file

@ -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;
}