diff mbox

Fix unaligned access found by addr. sanitizer

Message ID 1461433078-6799-1-git-send-email-msuraev@sysmocom.de
State New
Headers show

Commit Message

Max April 23, 2016, 5:37 p.m. UTC
From: Max <msuraev@sysmocom.de>

gprs_bssgp.c:461:9: runtime error: load of misaligned address
0x62100001a66b for type 'uint32_t', which requires 4 byte alignment

gprs_ns.c:937:16: runtime error: load of misaligned address
0x61d00002a97f for type 'uint16_t', which requires 2 byte alignment
---
 src/gb/gprs_bssgp.c | 4 ++--
 src/gb/gprs_ns.c    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/src/gb/gprs_bssgp.c b/src/gb/gprs_bssgp.c
index d9d8ccd..3ad2f29 100644
--- a/src/gb/gprs_bssgp.c
+++ b/src/gb/gprs_bssgp.c
@@ -416,7 +416,7 @@  static int bssgp_rx_suspend(struct msgb *msg, struct tlv_parsed *tp)
 		return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
 	}
 
-	tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI));
+	tlli = ntohl(tlvp_val32_unal(tp, BSSGP_IE_TLLI));
 
 	DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx SUSPEND\n",
 		ns_bvci, tlli);
@@ -458,7 +458,7 @@  static int bssgp_rx_resume(struct msgb *msg, struct tlv_parsed *tp)
 		return bssgp_tx_status(BSSGP_CAUSE_MISSING_MAND_IE, NULL, msg);
 	}
 
-	tlli = ntohl(*(uint32_t *)TLVP_VAL(tp, BSSGP_IE_TLLI));
+	tlli = ntohl(tlvp_val32_unal(tp, BSSGP_IE_TLLI));
 	suspend_ref = *TLVP_VAL(tp, BSSGP_IE_SUSPEND_REF_NR);
 
 	DEBUGP(DBSSGP, "BSSGP BVCI=%u TLLI=0x%08x Rx RESUME\n", ns_bvci, tlli);
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index a29c946..6879c70 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -934,8 +934,8 @@  static int gprs_ns_rx_reset_ack(struct gprs_nsvc **nsvc, struct msgb *msg)
 		return -EINVAL;
 	}
 
-	nsvci = ntohs(*(uint16_t *) TLVP_VAL(&tp, NS_IE_VCI));
-	nsei  = ntohs(*(uint16_t *) TLVP_VAL(&tp, NS_IE_NSEI));
+	nsvci = ntohs(tlvp_val16_unal(&tp, NS_IE_VCI));
+	nsei  = ntohs(tlvp_val16_unal(&tp, NS_IE_NSEI));
 
 	LOGP(DNS, LOGL_INFO, "NSVCI=%u%s Rx NS RESET ACK (NSEI=%u, NSVCI=%u)\n",
 	     (*nsvc)->nsvci, (*nsvc)->nsvci_is_valid ? "" : "(invalid)",