From 8722c7e7bc0a680b734da37e9a08b671d1f141ce Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 18 Dec 2023 14:52:53 +0100 Subject: [PATCH] siphash: make sure siphash24_compress_usec_t() works the same on LE/BE archs Let's be systematic here, and always hash LE values. It doesn't matter in our current codebase, but it might one day. --- src/basic/siphash24.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/basic/siphash24.h b/src/basic/siphash24.h index 0b3e845bf4..72147a9904 100644 --- a/src/basic/siphash24.h +++ b/src/basic/siphash24.h @@ -25,12 +25,12 @@ void siphash24_compress(const void *in, size_t inlen, struct siphash *state); static inline void siphash24_compress_boolean(bool in, struct siphash *state) { uint8_t i = in; - siphash24_compress(&i, sizeof i, state); } static inline void siphash24_compress_usec_t(usec_t in, struct siphash *state) { - siphash24_compress(&in, sizeof in, state); + uint64_t u = htole64(in); + siphash24_compress(&u, sizeof u, state); } static inline void siphash24_compress_safe(const void *in, size_t inlen, struct siphash *state) {