Review at  https://gerrit.osmocom.org/5839

gsm0480: parse all SS info elements in a message

Change-Id: I20cc59c25fdbda176bcf76437174cda829518d60
---
M src/gsm/gsm0480.c
1 file changed, 10 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/39/5839/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index e3856a5..0f30250 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -334,11 +334,15 @@
        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 @@
                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;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/5839
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I20cc59c25fdbda176bcf76437174cda829518d60
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Vadim Yanitskiy <axilira...@gmail.com>

Reply via email to