From 4e8b6f726dab50865d7daded2299d0187184901f Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sat, 27 Nov 2021 15:49:46 +0100 Subject: lib: Fix undefined behaviour in sha3 Arithmetic with NULL pointers is undefined behaviour. Caught by clang 13. Fixed by using uintptr_t, which is guaranteed to be the size of a pointer. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/lib/sha3.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/lib/sha3.c') diff --git a/src/lib/sha3.c b/src/lib/sha3.c index 74f971ab..76ddbae6 100644 --- a/src/lib/sha3.c +++ b/src/lib/sha3.c @@ -52,8 +52,7 @@ #include #include -#define IS_ALIGNED_64(p) (0 == (7 & ((const uint8_t *) (p) \ - - (const uint8_t *) 0))) +#define IS_ALIGNED_64(p) (0 == (7 & ((uintptr_t) (p)))) #define I64(x) x##LL #define ROTL64(qword, n) ((qword) << (n) ^ ((qword) >> (64 - (n)))) -- cgit v1.2.3