aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-06-21 10:22:26 +0800
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-06-21 16:57:14 +0800
commitc60465359b8579f88a761bfef1349ef879b4f0c5 (patch)
treed22a182fe9a81935ca25d36cc4321beba571992d
parente9eb4d1ab862f6dc94a5acc680836d30b483c0b6 (diff)
abis_nm.c: Reading the in_addr can lead to unaligned memory access
The value of the in_addr might not be 32 bit aligned and reading it can generate an alignment error on ARM. Fix it by using memcpy to copy the data into a local variable. There are many more potential alignment issues that we will fix when we hit them.
-rw-r--r--openbsc/src/abis_nm.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/openbsc/src/abis_nm.c b/openbsc/src/abis_nm.c
index 09285bd4..868502d5 100644
--- a/openbsc/src/abis_nm.c
+++ b/openbsc/src/abis_nm.c
@@ -2690,6 +2690,7 @@ static const char ipaccess_magic[] = "com.ipaccess";
static int abis_nm_rx_ipacc(struct msgb *msg)
{
+ struct in_addr addr;
struct abis_om_hdr *oh = msgb_l2(msg);
struct abis_om_fom_hdr *foh;
u_int8_t idstrlen = oh->data[0];
@@ -2711,10 +2712,12 @@ static int abis_nm_rx_ipacc(struct msgb *msg)
switch (foh->msg_type) {
case NM_MT_IPACC_RSL_CONNECT_ACK:
DEBUGPC(DNM, "RSL CONNECT ACK ");
- if (TLVP_PRESENT(&tp, NM_ATT_IPACC_DST_IP))
- DEBUGPC(DNM, "IP=%s ",
- inet_ntoa(*((struct in_addr *)
- TLVP_VAL(&tp, NM_ATT_IPACC_DST_IP))));
+ if (TLVP_PRESENT(&tp, NM_ATT_IPACC_DST_IP)) {
+ memcpy(&addr,
+ TLVP_VAL(&tp, NM_ATT_IPACC_DST_IP), sizeof(addr));
+
+ DEBUGPC(DNM, "IP=%s ", inet_ntoa(addr));
+ }
if (TLVP_PRESENT(&tp, NM_ATT_IPACC_DST_IP_PORT))
DEBUGPC(DNM, "PORT=%u ",
ntohs(*((u_int16_t *)