]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
shared: Use uint8_t in hash_superfast
authorTobias Stoeckmann <tobias@stoeckmann.org>
Fri, 15 Nov 2024 17:41:22 +0000 (18:41 +0100)
committerLucas De Marchi <demarchi@kernel.org>
Tue, 3 Feb 2026 04:58:53 +0000 (22:58 -0600)
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 <tobias@stoeckmann.org>
Link: https://github.com/kmod-project/kmod/pull/pull/248
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
shared/hash.c

index 9e1f5ea43a23b7eda89d4d61ce1b0cb8cbdc6baa..5573a9916db908c22bf1e01f59505fd1208071b2 100644 (file)
@@ -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;