bgpd: fix potential crash in community_list_dup_check
extcommunity_list_set may set the ->config for an entry
to NULL. In this case, the old code in community_list_dup_check
would cause a NULL pointer dereference.
Adjust the code so it behaves the same in the absence of NULL
pointers and otherwise checks if both are NULL to determine
equality.
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Tested-by: NetDEF CI System <cisystem@netdef.org>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index bb06028..1f1a4e7 100644
--- a/bgpd/bgp_clist.c
+++ b/bgpd/bgp_clist.c
@@ -644,7 +644,10 @@
break;
case COMMUNITY_LIST_EXPANDED:
case EXTCOMMUNITY_LIST_EXPANDED:
- if (strcmp (entry->config, new->config) == 0)
+ if (entry->config && new->config
+ && strcmp (entry->config, new->config) == 0)
+ return 1;
+ if (!entry->config && !new->config)
return 1;
break;
default: