Source: dovecot
Version: 1:2.4.5+dfsg1-1
Severity: serious
Tags: ftbfs upstream patch
X-Debbugs-Cc: [email protected]
User: [email protected]
Usertags: s390x
Dovecot includes an implementation of the xxh64 has algorithm. The
implementation contains an endianness bug that impacts builds on s390x and
other big-endian ports.
The issue is that xxh64 requires data to be stored in little-endian format,
but the dovecot implementation does not account for this when interpreting
multi-byte values as uint32_t and uint64_t. The solution is to call the
appropriate endian conversion function when reading these values from
memory.
The attached patch should accomplish this.
noah
Index: dovecot/src/lib/xxh64.c
===================================================================
--- dovecot.orig/src/lib/xxh64.c
+++ dovecot/src/lib/xxh64.c
@@ -8,6 +8,8 @@
#include "lib.h"
#include "xxh64.h"
+#include <endian.h>
+
#define XXH64_PRIME1 UINT64_C(0x9E3779B185EBCA87)
#define XXH64_PRIME2 UINT64_C(0xC2B2AE3D27D4EB4F)
#define XXH64_PRIME3 UINT64_C(0x165667B19E3779F9)
@@ -20,14 +22,14 @@ static inline uint64_t xxh64_read64(cons
{
uint64_t v;
memcpy(&v, p, sizeof(v));
- return v;
+ return le64toh(v); /* Convert from little-endian to host byte order */
}
static inline uint32_t xxh64_read32(const void *p)
{
uint32_t v;
memcpy(&v, p, sizeof(v));
- return v;
+ return le32toh(v); /* Convert from little-endian to host byte order */
}
static uint64_t ATTR_UNSIGNED_WRAPS xxh64_round(uint64_t acc, uint64_t input)