fixeria has uploaded this change for review. (
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(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/95/34995/1
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: 1
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-MessageType: newchange