aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Sperling <ssperling@sysmocom.de>2018-11-06 14:24:56 +0100
committerHarald Welte <laforge@gnumonks.org>2018-11-18 20:20:42 +0000
commit42f59d52f8c87a2f0992aa613b7b34564dc1ef3d (patch)
treea686a0c8637a87d9ae2846aadfebf0d74b631b05
parent42bd128ffc378904fe7683311e57d06c8c95edb6 (diff)
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
-rw-r--r--src/osmo-bsc/bsc_vty.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c
index b9a526808..f4f5838df 100644
--- a/src/osmo-bsc/bsc_vty.c
+++ b/src/osmo-bsc/bsc_vty.c
@@ -4493,10 +4493,11 @@ DEFUN(pdch_act, pdch_act_cmd,
}
/* 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 @@ static int lchan_set_single_amr_mode(struct gsm_lchan *lchan, uint8_t amr_mode)
/* 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 @@ DEFUN(lchan_act, lchan_act_cmd,
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);