From 8ec21cf12c25474f834254d49cdde0aac8642aab Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 14 Feb 2017 12:11:29 +0100 Subject: [PATCH] bgpd: set the returned buffer to '\0' in case is returns nothing In the case where extended communities to str function is called with a filtering mecanism, then the case that the returned buffer is not inited may happen. Hence the change done. Signed-off-by: Philippe Guibert --- bgpd/bgp_ecommunity.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index a5949728c2..5d4ba78c75 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -643,6 +643,7 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format, int filter) /* Prepare buffer. */ str_buf = XMALLOC (MTYPE_ECOMMUNITY_STR, ECOMMUNITY_STR_DEFAULT_LEN + 1); str_size = ECOMMUNITY_STR_DEFAULT_LEN + 1; + str_buf[0] = '\0'; str_pnt = 0; for (i = 0; i < ecom->size; i++) @@ -673,7 +674,6 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format, int filter) case ECOMMUNITY_ENCODE_OPAQUE: if(filter == ECOMMUNITY_ROUTE_TARGET) { - first = 0; continue; } if (*pnt == ECOMMUNITY_OPAQUE_SUBTYPE_ENCAP) @@ -693,7 +693,6 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format, int filter) case ECOMMUNITY_ENCODE_EVPN: if(filter == ECOMMUNITY_ROUTE_TARGET) { - first = 0; continue; } if (*pnt == ECOMMUNITY_SITE_ORIGIN) @@ -829,7 +828,6 @@ extern struct ecommunity_val *ecommunity_lookup (const struct ecommunity *ecom, { u_int8_t *p; int c; - struct ecommunity_val *ecom_val; /* If the value already exists in the structure return 0. */ c = 0; -- 2.39.5