laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/44177?usp=email ) Change subject: cbsp: cbsp_decode_cell_list(): do not reject empty cell list ...................................................................... cbsp: cbsp_decode_cell_list(): do not reject empty cell list 190fd93f broke CBSP TCs in ttcn3-bsc-test. The testsuite sends an empty cell list with id_discr set to CELL_IDENT_BSS. Apparently, this is legal and osmo-bsc interprets this as "all served cells". Change-Id: If69ae9a90fe2e582c909386d6fe6f32f017591af Fixes: 190fd93f ("cbsp: cbsp_decode_cell_list(): fix endless loop iteration") Related: OS#7098 --- M src/gsm/cbsp.c M tests/smscb/cbsp_test.c M tests/smscb/cbsp_test.ok 3 files changed, 11 insertions(+), 8 deletions(-) Approvals: laforge: Looks good to me, approved pespin: Looks good to me, but someone else must approve Jenkins Builder: Verified diff --git a/src/gsm/cbsp.c b/src/gsm/cbsp.c index 18b8226..233cbf3 100644 --- a/src/gsm/cbsp.c +++ b/src/gsm/cbsp.c @@ -521,8 +521,10 @@ 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"; + if (cell_id_size == 0) + return 0; /* empty list, nothing to parse */ + if (cell_id_size < 0) { + osmo_cbsp_errstr = "cell list: unexpected cell_id_discr"; return -EINVAL; } diff --git a/tests/smscb/cbsp_test.c b/tests/smscb/cbsp_test.c index 43b921c..f59dbc1 100644 --- a/tests/smscb/cbsp_test.c +++ b/tests/smscb/cbsp_test.c @@ -81,12 +81,13 @@ .hex_pdu = "0300002c0e003103417009000f0009f1070018003003012711c3510f04000f0009f1070017002a09f1070018002a1200", }, { - /* XXX: CELL_IDENT_BSS => empty cell list (fails) */ + /* CELL_IDENT_BSS => empty cell list */ .name = "CBSP RESET: Cell List (BSS)", .hex_pdu = "1000000404000106", }, { - /* XXX: CELL_IDENT_NO_CELL is not listed in 3GPP TS 48.049, 8.2.6 (fails) */ + /* CELL_IDENT_NO_CELL is not listed in 3GPP TS 48.049, 8.2.6, + * but we still parse it as an empty cell list */ .name = "CBSP RESET: Cell List (NO_CELL)", .hex_pdu = "1000000404000103", }, diff --git a/tests/smscb/cbsp_test.ok b/tests/smscb/cbsp_test.ok index f869d71..bbc1ff0 100644 --- a/tests/smscb/cbsp_test.ok +++ b/tests/smscb/cbsp_test.ok @@ -4,13 +4,13 @@ TC[0] osmo_cbsp_decode() result: pass TC[1] 'CBSP RESET: Cell List (BSS)' TC[1] PDU: 1000000404000106 -TC[1] osmo_cbsp_decode() result: cell list: unexpected cell_id_size +TC[1] osmo_cbsp_decode() result: pass TC[2] 'CBSP RESET: Cell List (NO_CELL)' TC[2] PDU: 1000000404000103 -TC[2] osmo_cbsp_decode() result: cell list: unexpected cell_id_size +TC[2] osmo_cbsp_decode() result: pass TC[3] 'CBSP RESET: Cell List (NO_CELL) with trailing bytes' TC[3] PDU: 1000000404000303ffff -TC[3] osmo_cbsp_decode() result: cell list: unexpected cell_id_size +TC[3] osmo_cbsp_decode() result: pass TC[4] 'CBSP RESET: Cell List (LAC, short)' TC[4] PDU: 1000000404000205ff TC[4] osmo_cbsp_decode() result: cell list: error decoding cell_id_union @@ -22,5 +22,5 @@ TC[6] osmo_cbsp_decode() result: error TC[7] 'CBSP RESET: Cell List (unknown discriminator)' TC[7] PDU: 100000040400010f -TC[7] osmo_cbsp_decode() result: cell list: unexpected cell_id_size +TC[7] osmo_cbsp_decode() result: cell list: unexpected cell_id_discr === test_decode end === -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/44177?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: If69ae9a90fe2e582c909386d6fe6f32f017591af Gerrit-Change-Number: 44177 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <vyanitskiy@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge <laforge@osmocom.org> Gerrit-Reviewer: osmith <osmith@sysmocom.de> Gerrit-Reviewer: pespin <pespin@sysmocom.de>