diff options
author | Daniel Mack <daniel@zonque.org> | 2015-11-16 13:08:34 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-04-26 12:58:55 +0200 |
commit | bc862a48dfd0c56cfdfefcf400dc92464e135a64 (patch) | |
tree | 49f1a9416622835d9d574788d01e7f5a6f7c8477 /src | |
parent | 75b4f90262d9c6cfc354f204d9981393daf08f98 (diff) |
siphash24: fix memory alignment
Use unaligned_read_le64() to access input buffer when reading complete
64-bit words.
This should fix memory traps on platforms with strict aliasing.
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/siphash24.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/basic/siphash24.c b/src/basic/siphash24.c index fa94f80ae..c7c465e5c 100644 --- a/src/basic/siphash24.c +++ b/src/basic/siphash24.c @@ -20,6 +20,7 @@ #include "sparse-endian.h" #include "siphash24.h" +#include "unaligned.h" #include "util.h" static inline uint64_t rotate_left(uint64_t x, uint8_t b) { @@ -104,7 +105,7 @@ void siphash24_compress(const void *_in, size_t inlen, struct siphash *state) { end -= ( state->inlen % sizeof (uint64_t) ); for ( ; in < end; in += 8 ) { - m = le64toh(*(le64_t*) in); + m = unaligned_read_le64(in); #ifdef DEBUG printf("(%3zu) v0 %08x %08x\n", state->inlen, (uint32_t) (state->v0 >> 32), (uint32_t) state->v0); printf("(%3zu) v1 %08x %08x\n", state->inlen, (uint32_t) (state->v1 >> 32), (uint32_t) state->v1); |