Change in osmocom-bb[master]: layer23: fix unaligned store in osmo_send_l1()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Sat Aug 11 12:59:31 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10431 )

Change subject: layer23: fix unaligned store in osmo_send_l1()
......................................................................

layer23: fix unaligned store in osmo_send_l1()

This fixes the following alignment issue uncovered by asan:

l1l2_interface.c:169:7: runtime error: store to misaligned address 0x61600001ab99 for type 'uint16_t', which requires 2 byte alignment
0x61600001ab99: note: pointer points here
 00 00 00  00 00 00 06 0a 01 19 19  40 18 00 07 00 01 03 49  06 15 00 40 01 c0 00 00  00 00 00 00 00
              ^

Change-Id: Ie65b428107d35bac99bc870fdbc4dc509ca2f33c
---
M src/host/layer23/src/common/l1l2_interface.c
1 file changed, 2 insertions(+), 5 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Vadim Yanitskiy: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/host/layer23/src/common/l1l2_interface.c b/src/host/layer23/src/common/l1l2_interface.c
index d89995d..956279d 100644
--- a/src/host/layer23/src/common/l1l2_interface.c
+++ b/src/host/layer23/src/common/l1l2_interface.c
@@ -157,16 +157,13 @@
 
 int osmo_send_l1(struct osmocom_ms *ms, struct msgb *msg)
 {
-	uint16_t *len;
-
 	DEBUGP(DL1C, "Sending: '%s'\n", osmo_hexdump(msg->data, msg->len));
 
 	if (msg->l1h != msg->data)
 		LOGP(DL1C, LOGL_ERROR, "Message L1 header != Message Data\n");
-	
+
 	/* prepend 16bit length before sending */
-	len = (uint16_t *) msgb_push(msg, sizeof(*len));
-	*len = htons(msg->len - sizeof(*len));
+	msgb_push_u16(msg, msg->len);
 
 	if (osmo_wqueue_enqueue(&ms->l2_wq, msg) != 0) {
 		LOGP(DL1C, LOGL_ERROR, "Failed to enqueue msg.\n");

-- 
To view, visit https://gerrit.osmocom.org/10431
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie65b428107d35bac99bc870fdbc4dc509ca2f33c
Gerrit-Change-Number: 10431
Gerrit-PatchSet: 2
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180811/3379f4e2/attachment.htm>


More information about the gerrit-log mailing list