]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: CVE-2011-3327 (ext. comm. buffer overflow)
authorCROSS <info@codenomicon.com>
Mon, 26 Sep 2011 09:17:05 +0000 (13:17 +0400)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 26 Sep 2011 14:46:16 +0000 (18:46 +0400)
This vulnerability (CERT-FI #513254) was reported by CROSS project.
They have also suggested a fix to the problem, which was found
acceptable.

The problem occurs when bgpd receives an UPDATE message containing
255 unknown AS_PATH attributes in Path Attribute Extended Communities.
This causes a buffer overlow in bgpd.

* bgp_ecommunity.c
  * ecommunity_ecom2str(): perform size check earlier

bgpd/bgp_ecommunity.c

index 8d91c7463850f3a35638faf4a6edc679e5216d04..440c15a4054c91fff1d52f1a7d892cc5712206a0 100644 (file)
@@ -620,6 +620,13 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format)
 
   for (i = 0; i < ecom->size; i++)
     {
+      /* Make it sure size is enough.  */
+      while (str_pnt + ECOMMUNITY_STR_DEFAULT_LEN >= str_size)
+       {
+         str_size *= 2;
+         str_buf = XREALLOC (MTYPE_ECOMMUNITY_STR, str_buf, str_size);
+       }
+
       /* Space between each value.  */
       if (! first)
        str_buf[str_pnt++] = ' ';
@@ -663,13 +670,6 @@ ecommunity_ecom2str (struct ecommunity *ecom, int format)
          break;
        }
 
-      /* Make it sure size is enough.  */
-      while (str_pnt + ECOMMUNITY_STR_DEFAULT_LEN >= str_size)
-       {
-         str_size *= 2;
-         str_buf = XREALLOC (MTYPE_ECOMMUNITY_STR, str_buf, str_size);
-       }
-
       /* Put string into buffer.  */
       if (encode == ECOMMUNITY_ENCODE_AS4)
        {