nat: Check for the access list in set command as well
I omitted the check as this was already done by the verify
function for this command. Please Coverity and do the check
again even if it is not necessary. I begin to doubt the
usage of a "dedicated" verify method as well.
Silences: Coverity CID 1293150
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
index 54e1dc4..4b59b40 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_ctrl.c
@@ -404,11 +404,18 @@
static int set_net_cfg_acc_cmd(struct ctrl_cmd *cmd, void *data)
{
const char *access_name = extract_acc_name(cmd->variable);
- struct bsc_nat_acc_lst *acc = bsc_nat_acc_lst_find(g_nat, access_name);
+ struct bsc_nat_acc_lst *acc;
struct bsc_nat_acc_lst_entry *entry;
const char *value = cmd->value;
int rc;
+ /* Should have been caught by verify_net_cfg_acc_cmd */
+ acc = bsc_nat_acc_lst_find(g_nat, access_name);
+ if (!acc) {
+ cmd->reply = "Access list not found";
+ return CTRL_CMD_ERROR;
+ }
+
entry = bsc_nat_acc_lst_entry_create(acc);
if (!entry) {
cmd->reply = "OOM";