Change in osmo-bsc[master]: check return value of gsm48_multirate_config()
Harald Welte
gerrit-no-reply at lists.osmocom.org
Sun Nov 18 20:20:42 UTC 2018
Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/11629 )
Change subject: check return value of gsm48_multirate_config()
......................................................................
check return value of gsm48_multirate_config()
Check the return value of gsm48_multirate_config() in function
lchan_set_single_amr_mode(). This prevents an invalid AMR mode
from being configured for a logical channel.
Because the VTY parsier limits the AMR mode range to 0-7 this
is just a theoretical issue. However, this fact is beyond the
understanding of a static code analyzer, and the absence of
error handling was indeed setting a bad example.
Change-Id: I61153a44e8b7a38332bf38718397be9b339d5f25
Related: CID#188940
---
M src/osmo-bsc/bsc_vty.c
1 file changed, 21 insertions(+), 6 deletions(-)
Approvals:
Neels Hofmeyr: Looks good to me, approved
Pau Espin Pedrol: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index b9a5268..f4f5838 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -4493,10 +4493,11 @@
}
/* configure the lchan for a single AMR mode (as specified) */
-static int lchan_set_single_amr_mode(struct gsm_lchan *lchan, uint8_t amr_mode)
+static int lchan_set_single_amr_mode(struct vty *vty, struct gsm_lchan *lchan, uint8_t amr_mode)
{
struct amr_multirate_conf mr;
struct gsm48_multi_rate_conf *mr_conf;
+ int rc, vty_rc = CMD_SUCCESS;
mr_conf = (struct gsm48_multi_rate_conf *) &mr.gsm48_ie;
if (amr_mode > 7)
@@ -4515,10 +4516,22 @@
/* encode this configuration into the lchan for both uplink and
* downlink direction */
- gsm48_multirate_config(lchan->mr_ms_lv, mr_conf, mr.ms_mode, mr.num_modes);
- gsm48_multirate_config(lchan->mr_bts_lv, mr_conf, mr.bts_mode, mr.num_modes);
+ rc = gsm48_multirate_config(lchan->mr_ms_lv, mr_conf, mr.ms_mode, mr.num_modes);
+ if (rc != 0) {
+ vty_out(vty,
+ "Invalid AMR multirate configuration (%s, amr mode %d, ms) - check parameters%s",
+ gsm_lchant_name(lchan->type), amr_mode, VTY_NEWLINE);
+ vty_rc = CMD_WARNING;
+ }
+ rc = gsm48_multirate_config(lchan->mr_bts_lv, mr_conf, mr.bts_mode, mr.num_modes);
+ if (rc != 0) {
+ vty_out(vty,
+ "Invalid AMR multirate configuration (%s, amr mode %d, bts) - check parameters%s",
+ gsm_lchant_name(lchan->type), amr_mode, VTY_NEWLINE);
+ vty_rc = CMD_WARNING;
+ }
- return 0;
+ return vty_rc;
}
/* Debug/Measurement command to activate a given logical channel
@@ -4574,14 +4587,16 @@
else if (!strcmp(codec_str, "efr"))
lchan->tch_mode = GSM48_CMODE_SPEECH_EFR;
else if (!strcmp(codec_str, "amr")) {
- int amr_mode;
+ int amr_mode, vty_rc;
if (argc < 7) {
vty_out(vty, "%% AMR requires specification of AMR mode%s", VTY_NEWLINE);
return CMD_WARNING;
}
amr_mode = atoi(argv[6]);
lchan->tch_mode = GSM48_CMODE_SPEECH_AMR;
- lchan_set_single_amr_mode(lchan, amr_mode);
+ vty_rc = lchan_set_single_amr_mode(vty, lchan, amr_mode);
+ if (vty_rc != CMD_SUCCESS)
+ return vty_rc;
}
vty_out(vty, "%% activating lchan %s%s", gsm_lchan_name(lchan), VTY_NEWLINE);
rsl_tx_chan_activ(lchan, RSL_ACT_TYPE_INITIAL, 0);
--
To view, visit https://gerrit.osmocom.org/11629
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I61153a44e8b7a38332bf38718397be9b339d5f25
Gerrit-Change-Number: 11629
Gerrit-PatchSet: 2
Gerrit-Owner: Stefan Sperling <ssperling at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181118/6a124ca5/attachment.html>
More information about the gerrit-log
mailing list