]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fixes bug in BGPv6 causing crash by checking missing attributes.
authorOndrej Zajicek <santiago@crfreenet.org>
Thu, 23 Apr 2009 10:36:24 +0000 (12:36 +0200)
committerOndrej Zajicek <santiago@crfreenet.org>
Thu, 23 Apr 2009 10:36:24 +0000 (12:36 +0200)
proto/bgp/attrs.c

index b7c5f2ebcef582e0574d7099ed3fa305f865e90c..57dce1467139c94796d551c39131900810a79048 100644 (file)
@@ -1359,17 +1359,19 @@ bgp_decode_attrs(struct bgp_conn *conn, byte *attr, unsigned int len, struct lin
     mandatory = 1;
 #endif
 
+
+  /* If there is no (reachability) NLRI, we should exit now */
+  if (! mandatory)
+    return a;
+
   /* Check if all mandatory attributes are present */
-  if (mandatory)
+  for(i=0; i < ARRAY_SIZE(bgp_mandatory_attrs); i++)
     {
-      for(i=0; i < ARRAY_SIZE(bgp_mandatory_attrs); i++)
+      code = bgp_mandatory_attrs[i];
+      if (!(seen[code/8] & (1 << (code%8))))
        {
-         code = bgp_mandatory_attrs[i];
-         if (!(seen[code/8] & (1 << (code%8))))
-           {
-             bgp_error(conn, 3, 3, &bgp_mandatory_attrs[i], 1);
-             return NULL;
-           }
+         bgp_error(conn, 3, 3, &bgp_mandatory_attrs[i], 1);
+         return NULL;
        }
     }