fixeria has submitted this change. ( https://gerrit.osmocom.org/c/libosmocore/+/34995?usp=email )
Change subject: coding: gsm0503_tch_a[fh]s_encode(): improve cmr/ft checks ...................................................................... coding: gsm0503_tch_a[fh]s_encode(): improve cmr/ft checks Change-Id: If03d5b015ab1c8db56a4c67bdc8e36e260c06562 --- M src/coding/gsm0503_coding.c 1 file changed, 19 insertions(+), 26 deletions(-) Approvals: laforge: Looks good to me, but someone else must approve Jenkins Builder: Verified osmith: Looks good to me, approved diff --git a/src/coding/gsm0503_coding.c b/src/coding/gsm0503_coding.c index 0e7f689..f8840c9 100644 --- a/src/coding/gsm0503_coding.c +++ b/src/coding/gsm0503_coding.c @@ -2465,19 +2465,11 @@ h = 0; - if (codec_mode_req) { - if (cmr >= codecs) { - /* FIXME: CMR ID is not in codec list! */ - return -1; - } - id = cmr; - } else { - if (ft >= codecs) { - /* FIXME: FT ID is not in codec list! */ - return -1; - } - id = ft; - } + id = codec_mode_req ? cmr : ft; + if (OSMO_UNLIKELY(id >= ARRAY_SIZE(gsm0503_afs_ic_ubit))) + return -1; + if (OSMO_UNLIKELY(ft >= codecs)) + return -1; switch (codec[ft]) { case 7: /* TCH/AFS12.2 */ @@ -2970,19 +2962,11 @@ h = 0; - if (codec_mode_req) { - if (cmr >= codecs) { - /* FIXME: CMR ID %d not in codec list */ - return -1; - } - id = cmr; - } else { - if (ft >= codecs) { - /* FIXME: FT ID %d not in codec list */ - return -1; - } - id = ft; - } + id = codec_mode_req ? cmr : ft; + if (OSMO_UNLIKELY(id >= ARRAY_SIZE(gsm0503_ahs_ic_ubit))) + return -1; + if (OSMO_UNLIKELY(ft >= codecs)) + return -1; switch (codec[ft]) { case 5: /* TCH/AHS7.95 */ -- To view, visit https://gerrit.osmocom.org/c/libosmocore/+/34995?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Change-Id: If03d5b015ab1c8db56a4c67bdc8e36e260c06562 Gerrit-Change-Number: 34995 Gerrit-PatchSet: 2 Gerrit-Owner: fixeria <vyanits...@sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanits...@sysmocom.de> Gerrit-Reviewer: laforge <lafo...@osmocom.org> Gerrit-Reviewer: osmith <osm...@sysmocom.de> Gerrit-MessageType: merged