From 9803c44bc445cb3446d6128e5debc578134216a4 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Fri, 15 Nov 2024 18:41:22 +0100 Subject: [PATCH] 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 --- shared/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/hash.c b/shared/hash.c index 38b7bb30..00da449a 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;