summaryrefslogtreecommitdiffstats
path: root/src/gsm
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2019-04-30 02:43:00 +0200
committerHarald Welte <laforge@gnumonks.org>2019-05-05 16:23:41 +0000
commitcc26a8b6c3ea439ef9ca314193a933c8505a8197 (patch)
treeab9ffbe987ac108b050133a6458bef1647d4a4dc /src/gsm
parent83d4531fa4543a601e4c9aa522503ef31024c417 (diff)
osmo_gsup_decode(): properly check IMSI, avoid deprecation
In osmo_gsup_decode(), call gsm48_decode_bcd_number2() to avoid deprecation warning, and also actually check the return value to detect invalid IMSI IEs. Change-Id: Iaded84d91baad5386c8f353c283b6b9e40a43b05
Diffstat (limited to 'src/gsm')
-rw-r--r--src/gsm/gsup.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/gsm/gsup.c b/src/gsm/gsup.c
index a3d9eef5..2e6690ee 100644
--- a/src/gsm/gsup.c
+++ b/src/gsm/gsup.c
@@ -332,9 +332,11 @@ int osmo_gsup_decode(const uint8_t *const_data, size_t data_len,
* before the value part already contains this length so we can use it
* here.
*/
- OSMO_ASSERT(value[-1] == value_len);
- gsm48_decode_bcd_number(gsup_msg->imsi, sizeof(gsup_msg->imsi),
- value - 1, 0);
+ if (gsm48_decode_bcd_number2(gsup_msg->imsi, sizeof(gsup_msg->imsi),
+ value - 1, value_len + 1, 0)) {
+ LOGP(DLGSUP, LOGL_ERROR, "Cannot decode IMSI\n");
+ return -GMM_CAUSE_INV_MAND_INFO;
+ }
/* specific parts */
while (data_len > 0) {