diff options
author | Neels Hofmeyr <neels@hofmeyr.de> | 2020-10-08 01:29:50 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2020-10-08 01:29:50 +0200 |
commit | f95f292c1570821d062c06cdbda68cec3101e236 (patch) | |
tree | 73f426b42ff7026c7e4cd93b84880716fde15c91 | |
parent | 2408eec3e25bdfdaacb65e550a6a6d76c5a8e7e4 (diff) |
do not pass length outside of msgb (1): bssmap_msg_len()
Change-Id: I047f1fe0710fcf7b9f8238a6063de9937e6ceb47
-rw-r--r-- | src/osmo-bsc/osmo_bsc_bssap.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c index ffa65d4a8..8db81acf3 100644 --- a/src/osmo-bsc/osmo_bsc_bssap.c +++ b/src/osmo-bsc/osmo_bsc_bssap.c @@ -1288,16 +1288,15 @@ int bsc_handle_udt(struct bsc_msc_data *msc, } /* Extract and verify the length information from the BSSMAP header. */ -static unsigned int bssmap_msg_len(struct msgb *msg, unsigned int length, +static unsigned int bssmap_msg_len(struct msgb *msg, const struct gsm_subscriber_connection *conn) { unsigned int expected_len; unsigned int calculated_len; struct bssmap_header *bssmap_header; - bssmap_header = (struct bssmap_header *)msg->l3h; - - calculated_len = length - sizeof(struct bssmap_header); + bssmap_header = msgb_l3(msg); + calculated_len = msgb_l3len(msg) - sizeof(struct bssmap_header); expected_len = bssmap_header->length; /* In case of contradictory length information, decide for the @@ -1329,7 +1328,7 @@ int bsc_handle_dt(struct gsm_subscriber_connection *conn, switch (msg->l3h[0]) { case BSSAP_MSG_BSS_MANAGEMENT: msg->l4h = &msg->l3h[sizeof(struct bssmap_header)]; - bssmap_rcvmsg_dt1(conn, msg, bssmap_msg_len(msg, msgb_l3len(msg), conn)); + bssmap_rcvmsg_dt1(conn, msg, bssmap_msg_len(msg, conn)); break; case BSSAP_MSG_DTAP: dtap_rcvmsg(conn, msg, msgb_l3len(msg)); |