]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: fix some NULL pointer dereference bugs
authorRenato Westphal <renato@opensourcerouting.org>
Fri, 19 Oct 2018 18:54:26 +0000 (15:54 -0300)
committerRenato Westphal <renato@opensourcerouting.org>
Sat, 20 Oct 2018 15:39:05 +0000 (12:39 -0300)
Other parts of the rfapi code also check if these pointers are NULL or
not before using them.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
bgpd/rfapi/bgp_rfapi_cfg.c

index cb45fc8da4d39748f5f6a850b1cc8f9ab00e7423..3c472dda482fe17832d0538683008ac9dccf1b8c 100644 (file)
@@ -1601,8 +1601,10 @@ DEFUN (vnc_nve_group_export_no_prefixlist,
        idx += 2; /* skip afi and keyword */
 
        if (is_bgp) {
-               if (idx == argc || strmatch(argv[idx]->arg,
-                                           rfg->plist_export_bgp_name[afi])) {
+               if (idx == argc
+                   || (rfg->plist_export_bgp_name[afi]
+                       && strmatch(argv[idx]->arg,
+                                   rfg->plist_export_bgp_name[afi]))) {
                        if (rfg->plist_export_bgp_name[afi])
                                free(rfg->plist_export_bgp_name[afi]);
                        rfg->plist_export_bgp_name[afi] = NULL;
@@ -1612,8 +1614,9 @@ DEFUN (vnc_nve_group_export_no_prefixlist,
                }
        } else {
                if (idx == argc
-                   || strmatch(argv[idx]->arg,
-                               rfg->plist_export_zebra_name[afi])) {
+                   || (rfg->plist_export_zebra_name[afi]
+                       && strmatch(argv[idx]->arg,
+                                   rfg->plist_export_zebra_name[afi]))) {
                        if (rfg->plist_export_zebra_name[afi])
                                free(rfg->plist_export_zebra_name[afi]);
                        rfg->plist_export_zebra_name[afi] = NULL;
@@ -1732,8 +1735,10 @@ DEFUN (vnc_nve_group_export_no_routemap,
        }
 
        if (is_bgp) {
-               if (idx == argc || strmatch(argv[idx]->arg,
-                                           rfg->routemap_export_bgp_name)) {
+               if (idx == argc
+                   || (rfg->routemap_export_bgp_name
+                       && strmatch(argv[idx]->arg,
+                                   rfg->routemap_export_bgp_name))) {
                        if (rfg->routemap_export_bgp_name)
                                free(rfg->routemap_export_bgp_name);
                        rfg->routemap_export_bgp_name = NULL;
@@ -1743,8 +1748,10 @@ DEFUN (vnc_nve_group_export_no_routemap,
                        vnc_direct_bgp_reexport_group_afi(bgp, rfg, AFI_IP6);
                }
        } else {
-               if (idx == argc || strmatch(argv[idx]->arg,
-                                           rfg->routemap_export_zebra_name)) {
+               if (idx == argc
+                   || (rfg->routemap_export_zebra_name
+                       && strmatch(argv[idx]->arg,
+                                   rfg->routemap_export_zebra_name))) {
                        if (rfg->routemap_export_zebra_name)
                                free(rfg->routemap_export_zebra_name);
                        rfg->routemap_export_zebra_name = NULL;