summaryrefslogtreecommitdiff
path: root/src/lib/sha3.c
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2021-11-27 15:49:46 +0100
committerSander Vrijders <sander@ouroboros.rocks>2021-12-06 17:51:55 +0100
commit4e8b6f726dab50865d7daded2299d0187184901f (patch)
tree7db60ecdf106398d5f966b98b7c26c0052d21474 /src/lib/sha3.c
parent697aacc07202debf88b582998e261cb68f06ae25 (diff)
downloadouroboros-4e8b6f726dab50865d7daded2299d0187184901f.tar.gz
ouroboros-4e8b6f726dab50865d7daded2299d0187184901f.zip
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 <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'src/lib/sha3.c')
-rw-r--r--src/lib/sha3.c3
1 files changed, 1 insertions, 2 deletions
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 <assert.h>
#include <string.h>
-#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))))