aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2019-02-18 13:02:00 +0100
committerHarald Welte <laforge@gnumonks.org>2019-03-19 13:39:14 +0000
commit31f4c1f927352a5e50348b80bb61f3c8b4cdc799 (patch)
tree17a3f176d0adaa7ad852b3a1796406ddd753ceb3
parent9286114f6f9a8b45e620ccf2014ed713c770c9ed (diff)
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
-rw-r--r--src/libmsc/a_iface.c13
1 files changed, 13 insertions, 0 deletions
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 @@ static int a_iface_tx_bssap(const struct ran_conn *conn, struct msgb *msg)
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);
}