diff options
author | Oliver Smith <osmith@sysmocom.de> | 2023-06-22 10:39:24 +0200 |
---|---|---|
committer | osmith <osmith@sysmocom.de> | 2023-06-23 10:38:46 +0000 |
commit | 17399803a4fca01b1eaa505fe563b241f075f5c0 (patch) | |
tree | 4c4b50f9bc31a7415832dddd37c23d336408ac17 | |
parent | 0d4607d90d34ca2a75a11ac3458d63141b4de44c (diff) |
csd_bs_list_to_gsm0808_channel_type: fix rc check
Check the return code before writing it to unsigned ct->data_rate, as
"ct->data_rate < 0" is never true.
Fixes: CID#321277
Fixes: 106321 ("Add initial CSD support with external MNCC")
Change-Id: I5d77da71b60748818ba631229126c1bf061a9c7d
-rw-r--r-- | src/libmsc/csd_bs.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libmsc/csd_bs.c b/src/libmsc/csd_bs.c index adb92937b..2322f2094 100644 --- a/src/libmsc/csd_bs.c +++ b/src/libmsc/csd_bs.c @@ -375,14 +375,16 @@ int csd_bs_list_to_gsm0808_channel_type(struct gsm0808_channel_type *ct, const s if (csd_bs_is_transp(list->bs[0])) { ct->data_transparent = true; - ct->data_rate = csd_bs_to_gsm0808_data_rate_transp(list->bs[0]); + rc = csd_bs_to_gsm0808_data_rate_transp(list->bs[0]); } else { - ct->data_rate = csd_bs_to_gsm0808_data_rate_non_transp(list->bs[0]); + rc = csd_bs_to_gsm0808_data_rate_non_transp(list->bs[0]); } - if (ct->data_rate < 0) + if (rc < 0) return -EINVAL; + ct->data_rate = rc; + /* Other possible data rates allowed (3GPP TS 48.008 ยง 3.2.2.11, 5a) */ if (!ct->data_transparent && list->count > 1) { for (i = 1; i < list->count; i++) { |