summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouis Scalbert <louis.scalbert@6wind.com>2024-01-23 09:16:24 +0100
committerLouis Scalbert <louis.scalbert@6wind.com>2024-01-23 12:04:49 +0100
commit8c8bb3568a581691403493354d4a1fad02f24c91 (patch)
tree4927f2fec077fc28605fde3427a6643bf730606e
parentMerge pull request #15179 from donaldsharp/zebra_neigh_update (diff)
downloadfrr-8c8bb3568a581691403493354d4a1fad02f24c91.tar.xz
frr-8c8bb3568a581691403493354d4a1fad02f24c91.zip
bgpd: fix potential null pointers in rpki
Fix potential NULL pointer in RPKI code. Coverity scanner issues: 1575911 1575913, 1575915, 1575917, 1575919 to 1575923, 1575925 and 1575926. Fixes: 1420189c11 ("bgpd: add support of rpki in vrf configure context") Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
-rw-r--r--bgpd/bgp_rpki.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index 219cb2998..332f3c8de 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -1621,11 +1621,15 @@ DEFUN_NOSH (rpki,
{
struct rpki_vrf *rpki_vrf;
char *vrfname = NULL;
+ struct vrf *vrf;
if (vty->node == CONFIG_NODE)
vty->node = RPKI_NODE;
else {
- struct vrf *vrf = VTY_GET_CONTEXT(vrf);
+ vrf = VTY_GET_CONTEXT(vrf);
+
+ if (!vrf)
+ return CMD_WARNING;
vty->node = RPKI_VRF_NODE;
if (vrf->vrf_id != VRF_DEFAULT)
@@ -1732,6 +1736,9 @@ DEFPY (rpki_polling_period,
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
rpki_vrf->polling_period = pp;
return CMD_SUCCESS;
}
@@ -1751,6 +1758,9 @@ DEFUN (no_rpki_polling_period,
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
rpki_vrf->polling_period = POLLING_PERIOD_DEFAULT;
return CMD_SUCCESS;
}
@@ -1769,6 +1779,9 @@ DEFPY (rpki_expire_interval,
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
if ((unsigned int)tmp >= rpki_vrf->polling_period) {
rpki_vrf->expire_interval = tmp;
return CMD_SUCCESS;
@@ -1793,6 +1806,9 @@ DEFUN (no_rpki_expire_interval,
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
rpki_vrf->expire_interval = rpki_vrf->polling_period * 2;
return CMD_SUCCESS;
}
@@ -1811,6 +1827,9 @@ DEFPY (rpki_retry_interval,
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
rpki_vrf->retry_interval = tmp;
return CMD_SUCCESS;
}
@@ -1830,6 +1849,9 @@ DEFUN (no_rpki_retry_interval,
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
rpki_vrf->retry_interval = RETRY_INTERVAL_DEFAULT;
return CMD_SUCCESS;
}
@@ -1861,6 +1883,9 @@ DEFPY(rpki_cache, rpki_cache_cmd,
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
if (!rpki_vrf || !rpki_vrf->cache_list)
return CMD_WARNING;
@@ -1930,6 +1955,9 @@ DEFPY (no_rpki_cache,
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
cache_list = rpki_vrf->cache_list;
cache_p = find_cache(preference, cache_list);
if (!rpki_vrf || !cache_p) {
@@ -2422,6 +2450,10 @@ static int config_on_exit(struct vty *vty)
rpki_vrf = VTY_GET_CONTEXT_SUB(rpki_vrf);
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
reset(false, rpki_vrf);
return 1;
}
@@ -2454,6 +2486,10 @@ DEFPY (rpki_reset_config_mode,
rpki_vrf = VTY_GET_CONTEXT_SUB(rpki_vrf);
else
rpki_vrf = VTY_GET_CONTEXT(rpki_vrf);
+
+ if (!rpki_vrf)
+ return CMD_WARNING_CONFIG_FAILED;
+
return reset(true, rpki_vrf) == SUCCESS ? CMD_SUCCESS : CMD_WARNING;
}