summaryrefslogtreecommitdiffstats
path: root/src/gsm
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-01-17 12:18:27 +0600
committerHarald Welte <laforge@gnumonks.org>2018-01-17 10:45:41 +0000
commitb92a27f6944b7fa6f9297a5588b2d9177aa3728b (patch)
tree4dacffd98e662c6b546559c2b3ff51fc8c1d95ef /src/gsm
parentac3b6ac3011d0544f6f04c320ba78df93659f72c (diff)
gsm0480: parse all SS info elements in a message
Some SS messages (e.g. RELEASE COMPLETE) may contai multiple IEs (Information Elements). Let's parse them all. Change-Id: I20cc59c25fdbda176bcf76437174cda829518d60
Diffstat (limited to 'src/gsm')
-rw-r--r--src/gsm/gsm0480.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index e3856a56..0f302502 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -334,11 +334,15 @@ static int parse_ss_info_elements(const uint8_t *ss_ie, uint16_t len,
uint8_t iei;
uint8_t iei_length;
+ /* We need at least two bytes */
+ if (len < 2)
+ return 0;
+
iei = ss_ie[0];
iei_length = ss_ie[1];
/* If the data does not fit, report an error */
- if (len - 2 < iei_length)
+ if (iei_length + 2 > len)
return 0;
switch (iei) {
@@ -356,6 +360,11 @@ static int parse_ss_info_elements(const uint8_t *ss_ie, uint16_t len,
break;
}
+ /* A message may contain multiple IEs */
+ if (iei_length + 2 + 2 < len)
+ rc &= parse_ss_info_elements(ss_ie + iei_length + 2,
+ len - iei_length - 2, req);
+
return rc;
}