diff options
author | Philipp Maier <pmaier@sysmocom.de> | 2017-04-20 18:40:37 +0200 |
---|---|---|
committer | Neels Hofmeyr <nhofmeyr@sysmocom.de> | 2017-07-25 01:06:57 +0200 |
commit | 7e77a293a58cf3b324b37fa61d6189a386b9e62e (patch) | |
tree | 39527383b33e2e8801bbffc08d3b90550baf302d /src/libmsc | |
parent | 2932bc4955d2c4c802cb450621fbc2207dc6f8fa (diff) |
libmsc: make pitfall in gsm0408_dispatch() more obvious
The function gsm0408_dispatch() accepts a message buffer pointer
and accesses the l3h pointer. Even in a properly allocated
message buffer, this may lead into a segfault if the user forgets
to set the l3h pointer. This commit adds assertions to popup a
more expressive error message.
Change-Id: I43bd9bd1c170559aaa8dacaef25dba090744bcd5
Diffstat (limited to 'src/libmsc')
-rw-r--r-- | src/libmsc/gsm_04_08.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c index 21048c1cd..7bcea30f9 100644 --- a/src/libmsc/gsm_04_08.c +++ b/src/libmsc/gsm_04_08.c @@ -3012,13 +3012,17 @@ void cm_service_request_concludes(struct gsm_subscriber_connection *conn, /* Main entry point for GSM 04.08/44.008 Layer 3 data (e.g. from the BSC). */ int gsm0408_dispatch(struct gsm_subscriber_connection *conn, struct msgb *msg) { - struct gsm48_hdr *gh = msgb_l3(msg); - uint8_t pdisc = gsm48_hdr_pdisc(gh); + struct gsm48_hdr *gh; + uint8_t pdisc; int rc = 0; + OSMO_ASSERT(msg->l3h) OSMO_ASSERT(conn); OSMO_ASSERT(msg); + gh = msgb_l3(msg); + pdisc = gsm48_hdr_pdisc(gh); + LOGP(DRLL, LOGL_DEBUG, "Dispatching 04.08 message %s (0x%x:0x%x)\n", gsm48_pdisc_msgtype_name(pdisc, gsm48_hdr_msg_type(gh)), pdisc, gsm48_hdr_msg_type(gh)); |