diff --git a/policycoreutils/newrole/newrole.c b/policycoreutils/newrole/newrole.c index d9efa68a..5a1a1129 100644 --- a/policycoreutils/newrole/newrole.c +++ b/policycoreutils/newrole/newrole.c @@ -229,16 +229,13 @@ static int free_hashtab_entry(hashtab_key_t key, hashtab_datum_t d, static unsigned int reqsymhash(hashtab_t h, const_hashtab_key_t key) { - const char *p; - size_t size; - unsigned int val; + unsigned int hash = 5381; + unsigned char c; - val = 0; - size = strlen(key); - for (p = key; ((size_t) (p - key)) < size; p++) - val = - (val << 4 | (val >> (8 * sizeof(unsigned int) - 4))) ^ (*p); - return val & (h->size - 1); + while ((c = *(unsigned const char *)key++)) + hash = ((hash << 5) + hash) ^ c; + + return hash & (h->size - 1); } static int reqsymcmp(hashtab_t h