aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-05-22 12:17:20 +0200
committerStefan Sperling <ssperling@sysmocom.de>2018-05-24 13:06:46 +0000
commit5de80ca696da1ba94bed600c24398065877ac38b (patch)
treebbeba94dd26b996d88ba408dd796434fae3928e5
parent02d20da18348c5e45e2e4934d246f33b966fdf7a (diff)
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
-rw-r--r--src/libbsc/abis_nm.c2
1 files changed, 1 insertions, 1 deletions
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)