]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: set the returned buffer to '\0' in case is returns nothing
authorPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 14 Feb 2017 11:11:29 +0000 (12:11 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 14 Feb 2017 12:59:00 +0000 (13:59 +0100)
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 <philippe.guibert@6wind.com>
bgpd/bgp_ecommunity.c

index a5949728c259e15728ef88a34073ba68a045ebcc..5d4ba78c75783b5fd2055ded7c1153f8582c13f2 100644 (file)
@@ -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;