[XS] Change in libosmocore[master]: cbsp: cbsp_decode_cell_list(): fix endless loop iteration
fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/44160?usp=email ) Change subject: cbsp: cbsp_decode_cell_list(): fix endless loop iteration ...................................................................... cbsp: cbsp_decode_cell_list(): fix endless loop iteration gsm0808_cell_id_size() returns 0 for CELL_IDENT_{BSS,NO_CELL}, and may also return a negative (-EINVAL), so we cannot *blindly* use its result to advance the *cur pointer. Let's cache the value outside of the loop and check it beforehand. Change-Id: I03e7548baef1e8703668de1a20d31c69bf87caf3 Related: f2210030 ("cbsp: Fix endless loop iteration when decoding cell list IEs") Fixes: OS#7098 --- M src/gsm/cbsp.c 1 file changed, 8 insertions(+), 1 deletion(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/60/44160/1 diff --git a/src/gsm/cbsp.c b/src/gsm/cbsp.c index b355eef..f6ac79a 100644 --- a/src/gsm/cbsp.c +++ b/src/gsm/cbsp.c @@ -507,6 +507,7 @@ const uint8_t *buf, unsigned int len) { const uint8_t *cur = buf; + int cell_id_size; int rc; if (buf == NULL) { @@ -519,6 +520,12 @@ cl->id_discr = *cur++; + cell_id_size = gsm0808_cell_id_size(cl->id_discr); + if (cell_id_size <= 0) { + osmo_cbsp_errstr = "cell list: unexpected cell_id_size"; + return -EINVAL; + } + while (cur < buf + len) { struct osmo_cbsp_cell_ent *ent = talloc_zero(ctx, struct osmo_cbsp_cell_ent); unsigned int len_remain = len - (cur - buf); @@ -528,7 +535,7 @@ osmo_cbsp_errstr = "cell list: error decoding cell_id_union"; return rc; } - cur += gsm0808_cell_id_size(cl->id_discr); + cur += cell_id_size; llist_add_tail(&ent->list, &cl->list); } return 0; -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/44160?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: I03e7548baef1e8703668de1a20d31c69bf87caf3 Gerrit-Change-Number: 44160 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de>
participants (1)
-
fixeria