1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-22 17:35:59 +03:00

Fix hash function to avoid using a negative array offset.

This commit is contained in:
Alasdair Kergon 2006-01-09 20:35:24 +00:00
parent 079ac15ece
commit b6b0c621f6
2 changed files with 3 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Version 1.02.03 - Version 1.02.03 -
============================ ============================
Fix hash function to avoid using a negative array offset.
Don't inline _find in hash.c and tidy signed/unsigned etc. Don't inline _find in hash.c and tidy signed/unsigned etc.
Fix libdevmapper.h #endif. Fix libdevmapper.h #endif.
Fix dmsetup version driver version. Fix dmsetup version driver version.

View File

@ -68,14 +68,14 @@ static struct dm_hash_node *_create_node(const char *str, unsigned len)
return n; return n;
} }
static unsigned long _hash(const char *str, unsigned len) static unsigned long _hash(const unsigned char *str, unsigned len)
{ {
unsigned long h = 0, g; unsigned long h = 0, g;
unsigned i; unsigned i;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
h <<= 4; h <<= 4;
h += _nums[(int) *str++]; h += _nums[*str++];
g = h & ((unsigned long) 0xf << 16u); g = h & ((unsigned long) 0xf << 16u);
if (g) { if (g) {
h ^= g >> 16u; h ^= g >> 16u;