[tor-commits] [tor/master] Fix a ubsan warning in our ctypes replacements
nickm at torproject.org
nickm at torproject.org
Tue Apr 1 21:15:19 UTC 2014
commit 2aea6ca3260cee82a60168c047f4d0cc71f7c652
Author: Nick Mathewson <nickm at torproject.org>
Date: Tue Mar 18 10:47:26 2014 -0400
Fix a ubsan warning in our ctypes replacements
ubsan doesn't like 1<<31, since that's an undefined integer
overflow. Instead, we should do 1u<<31.
---
src/common/compat.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/common/compat.h b/src/common/compat.h
index 32effa5..30a3303 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -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)
More information about the tor-commits
mailing list