Change in osmo-msc[master]: a_iface: OSMO_ASSERT() if we ever want to send BSSAP with invalid length

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Mar 19 13:39:14 UTC 2019


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

Change subject: a_iface: OSMO_ASSERT() if we ever want to send BSSAP with invalid length
......................................................................

a_iface: OSMO_ASSERT() if we ever want to send BSSAP with invalid length

Let's add a safeguard against sending BSSAP messages with invalid length
values.  This should never happen, and we'd rather see osmo-msc assert
during the development cycle than ever releasing a version which sends
invalid messages out on the wire.

Change-Id: I94327a0d276c65b528a8c7e33dde61ed53582284
Related: OS#3805
---
M src/libmsc/a_iface.c
1 file changed, 13 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/libmsc/a_iface.c b/src/libmsc/a_iface.c
index 9a7dcd0..91a2b6a 100644
--- a/src/libmsc/a_iface.c
+++ b/src/libmsc/a_iface.c
@@ -148,6 +148,19 @@
 	OSMO_ASSERT(conn->a.scu);
 
 	LOGPCONN(conn, LOGL_DEBUG, "N-DATA.req(%s)\n", msgb_hexdump_l3(msg));
+
+	/* some consistency checks to ensure we don't send invalid length */
+	switch (msg->l3h[0]) {
+	case BSSAP_MSG_DTAP:
+		OSMO_ASSERT(msgb_l3len(msg) == msg->l3h[2] + 3);
+		break;
+	case BSSAP_MSG_BSS_MANAGEMENT:
+		OSMO_ASSERT(msgb_l3len(msg) == msg->l3h[1] + 2);
+		break;
+	default:
+		break;
+	}
+
 	return osmo_sccp_tx_data_msg(conn->a.scu, conn->a.conn_id, msg);
 }
 

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

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I94327a0d276c65b528a8c7e33dde61ed53582284
Gerrit-Change-Number: 12928
Gerrit-PatchSet: 3
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190319/ada53a96/attachment.html>


More information about the gerrit-log mailing list