From 08621a8ebb163aed6ba96e52ad283b91c04501a0 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 21 Jan 2016 17:16:56 +0100 Subject: bitvec: Fix unaligned memory access in osmo_revbytebits_buf The undefined behavior sanitizer found the 32bit load from an unaligned memory address. This will cause an exception on ARMv5te and a manual fix-up. [hfreyther: On armv6, x86 the usage of memcpy leads to shorter amount of instructions but on armv5te the memcpy is not expanded leading to a branch. Use the version of max until we have the time to benchmark it] Sponsored-by: On-Waves ehf --- src/bits.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/bits.c b/src/bits.c index 01d7e735..a0a9d9e8 100644 --- a/src/bits.c +++ b/src/bits.c @@ -221,8 +221,7 @@ void osmo_revbytebits_buf(uint8_t *buf, int len) } for (i = unaligned_cnt; i + 3 < len; i += 4) { - uint32_t *cur = (uint32_t *) (buf + i); - *cur = osmo_revbytebits_32(*cur); + osmo_store32be(osmo_revbytebits_32(osmo_load32be(buf + i)), buf + i); len_remain -= 4; } -- cgit v1.2.3