From 5de80ca696da1ba94bed600c24398065877ac38b Mon Sep 17 00:00:00 2001 From: Stefan Sperling Date: Tue, 22 May 2018 12:17:20 +0200 Subject: fix misaligned memory write access in abis_nm_ipaccess_rsl_connect() Use memcpy() to avoid unaligned access, instead of writing through a pointer cast to uint32_t. Problem spotted by address sanitizer: abis_nm.c:2802:24: runtime error: store to misaligned address 0x7ffc95396706 for type 'uint32_t', which requires 4 byte alignment 0x7ffc95396706: note: pointer points here 81 0b bb 80 00 00 00 00 ed 79 28 56 00 00 e0 9c 00 00 a0 61 00 00 ... ^ Related: OS#3196 Change-Id: I8e591a56ae522b371da01ea968151a7e6fa24bb9 --- src/libbsc/abis_nm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libbsc/abis_nm.c b/src/libbsc/abis_nm.c index b2cfa531d..ea94d3766 100644 --- a/src/libbsc/abis_nm.c +++ b/src/libbsc/abis_nm.c @@ -2799,7 +2799,7 @@ int abis_nm_ipaccess_rsl_connect(struct gsm_bts_trx *trx, attr[1] = stream; attr[3] = port >> 8; attr[4] = port & 0xff; - *(uint32_t *)(attr+6) = ia.s_addr; + memcpy(attr + 6, &ia.s_addr, sizeof(uint32_t)); /* if ip == 0, we use the default IP */ if (ip == 0) -- cgit v1.2.3