]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix a ubsan warning in our ctypes replacements
authorNick Mathewson <nickm@torproject.org>
Tue, 18 Mar 2014 14:47:26 +0000 (10:47 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 18 Mar 2014 14:47:26 +0000 (10:47 -0400)
ubsan doesn't like 1<<31, since that's an undefined integer
overflow.  Instead, we should do 1u<<31.

src/common/compat.h

index 32effa5c7408399c36965b63527a8aebfe29016c..30a33031cea701d231e989eedf0e852f5922a9b1 100644 (file)
@@ -321,7 +321,7 @@ tor_memstr(const void *haystack, size_t hlen, const char *needle)
   extern const uint32_t TOR_##name##_TABLE[];                           \
   static INLINE int TOR_##name(char c) {                                \
     uint8_t u = c;                                                      \
-    return !!(TOR_##name##_TABLE[(u >> 5) & 7] & (1 << (u & 31)));      \
+    return !!(TOR_##name##_TABLE[(u >> 5) & 7] & (1u << (u & 31)));     \
   }
 DECLARE_CTYPE_FN(ISALPHA)
 DECLARE_CTYPE_FN(ISALNUM)