]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: str_hash() - Ignore integer wrapping with ubsan
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 1 Oct 2021 12:21:38 +0000 (15:21 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Fri, 1 Oct 2021 19:30:26 +0000 (19:30 +0000)
ATTR_NO_SANITIZE_INTEGER was already set for other hash functions, but
forgotten for this one.

Fixes e.g.:
Error: hash.c:529:16: runtime error: unsigned integer overflow: 4294967200 + 115 cannot be represented in type â€˜unsigned int’

src/lib/hash.c

index 16f3c967238a148eadecf70f96a71d89b21ea63a..5530de19a10de601cc0a4a7252b73aece388d606 100644 (file)
@@ -520,7 +520,8 @@ void hash_table_copy(struct hash_table *dest, struct hash_table *src)
 }
 
 /* a char* hash function from ASU -- from glib */
-unsigned int str_hash(const char *p)
+unsigned int ATTR_NO_SANITIZE_INTEGER
+str_hash(const char *p)
 {
         const unsigned char *s = (const unsigned char *)p;
        unsigned int g, h = 0;