laforge submitted this change.

View Change

Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified
cbsp: cbsp_decode_cell_list(): check *buf/len

The callers of this function pass *buf/len as follows:

cbsp_decode_cell_list(..., TLVP_VAL(tp, CBSP_IEI_CELL_LIST),
TLVP_LEN(tp, CBSP_IEI_CELL_LIST));

so the *buf is NULL if the Cell List IE is not present. The IE
length is also not guaranteed to be valid: it can be 0. Thus
we should not be dereferencing the *buf unconditionally.

Change-Id: I31c66fad36f380fb6706a935df412fd6114f4cd9
Fixes: OS#7097
---
M src/gsm/cbsp.c
1 file changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/gsm/cbsp.c b/src/gsm/cbsp.c
index bc8bc4f..b355eef 100644
--- a/src/gsm/cbsp.c
+++ b/src/gsm/cbsp.c
@@ -509,6 +509,14 @@
const uint8_t *cur = buf;
int rc;

+ if (buf == NULL) {
+ osmo_cbsp_errstr = "cell list: missing mandatory IE";
+ return -ENOENT;
+ } else if (len < 1) {
+ osmo_cbsp_errstr = "cell list: too short";
+ return -EINVAL;
+ }
+
cl->id_discr = *cur++;

while (cur < buf + len) {

To view, visit change 44159. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I31c66fad36f380fb6706a935df412fd6114f4cd9
Gerrit-Change-Number: 44159
Gerrit-PatchSet: 2
Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-CC: pespin <pespin@sysmocom.de>