]> git.puffer.fish Git - mirror/frr.git/commitdiff
staticd: Check against NULL before dereferencing vrf 14452/head
authorDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 20 Sep 2023 12:24:25 +0000 (15:24 +0300)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Wed, 20 Sep 2023 12:25:29 +0000 (15:25 +0300)
If VRF is not found by the given name, validate it and return an error.

Fixes: 76b2bc97e738 ("staticd: Accept full blackhole typed keywords for ip_route_cmd")
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
staticd/static_nb_config.c

index 6673cce108b34cd30d8eefb233aa460bc476e088..520a3ee2c19bc0d88aa2782d15be59d244ba8336 100644 (file)
@@ -382,6 +382,13 @@ static int static_nexthop_bh_type_modify(struct nb_cb_modify_args *args)
                nh_vrf = yang_dnode_get_string(args->dnode, "../vrf");
                if (nh_ifname && nh_vrf) {
                        struct vrf *vrf = vrf_lookup_by_name(nh_vrf);
+
+                       if (!vrf) {
+                               snprintf(args->errmsg, args->errmsg_len,
+                                        "nexthop vrf %s not found", nh_vrf);
+                               return NB_ERR_VALIDATION;
+                       }
+
                        struct interface *ifp = if_lookup_by_name(nh_ifname,
                                                                  vrf->vrf_id);