From: Tobias Stoeckmann Date: Fri, 15 Nov 2024 17:41:22 +0000 (+0100) Subject: shared: Use uint8_t in hash_superfast X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38e0e4ad3426b583689baf7fbbdaf4d7c83323c7;p=thirdparty%2Fkmod.git shared: Use uint8_t in hash_superfast Characters in key are supposed to be handled unsigned. Explicitly cast key[2] in case the key contains 8-bit ASCII. Even though we cannot support such keys in indices, we might still use them in module names and tools like modinfo. Signed-off-by: Tobias Stoeckmann Link: https://github.com/kmod-project/kmod/pull/pull/248 Signed-off-by: Lucas De Marchi --- diff --git a/shared/hash.c b/shared/hash.c index 9e1f5ea4..5573a991 100644 --- a/shared/hash.c +++ b/shared/hash.c @@ -94,7 +94,7 @@ static inline unsigned int hash_superfast(const char *key, unsigned int len) case 3: hash += get_unaligned((uint16_t *)key); hash ^= hash << 16; - hash ^= key[2] << 18; + hash ^= ((uint8_t)key[2]) << 18; hash += hash >> 11; break;