Stefan Sperling has uploaded this change for review. ( 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(-) git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/29/11629/1 diff --git a/src/osmo-bsc/bsc_vty.c b/src/osmo-bsc/bsc_vty.c index 410cdac..0b951c0 100644 --- a/src/osmo-bsc/bsc_vty.c +++ b/src/osmo-bsc/bsc_vty.c @@ -4483,10 +4483,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) @@ -4505,10 +4506,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 @@ -4564,14 +4577,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: newchange Gerrit-Change-Id: I61153a44e8b7a38332bf38718397be9b339d5f25 Gerrit-Change-Number: 11629 Gerrit-PatchSet: 1 Gerrit-Owner: Stefan Sperling <ssperl...@sysmocom.de>