]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: trivial format / warning fixes
authorPaul Jakma <paul@quagga.net>
Mon, 11 Apr 2011 15:31:43 +0000 (16:31 +0100)
committerPaul Jakma <paul@quagga.net>
Wed, 13 Apr 2011 14:13:33 +0000 (15:13 +0100)
* bgp_aspath.c: (assegments_parse) just bail early if length doesn't match
  and fix the formatting.
* bgp_network.c: add include needed for set_nonblocking
* bgp_packet.c: formatting

bgpd/bgp_aspath.c
bgpd/bgp_network.c
bgpd/bgp_packet.c

index 5a73eeffae8650d503d36a3c3af227d9fdd7ba7c..cf930427094ac06a2fe893267a44575e5c7ee93e 100644 (file)
@@ -698,8 +698,12 @@ assegments_parse (struct stream *s, size_t length, int use32bit, int as4_path)
       size_t seg_size;
       
       /* softly softly, get the header first on its own */
-      if (length >= AS_HEADER_SIZE)
+      if (length < AS_HEADER_SIZE)
         {
+          assegment_free_all (head);
+          return NULL;
+        }
+      
       segh.type = stream_getc (s);
       segh.length = stream_getc (s);
       
@@ -710,26 +714,23 @@ assegments_parse (struct stream *s, size_t length, int use32bit, int as4_path)
        zlog_debug ("[AS4SEG] Parse aspath segment: got type %d, length %d",
                     segh.type, segh.length);
       
-          switch (segh.type)
-          {
-            case AS_SEQUENCE:
-            case AS_SET:
-              break ;
+      switch (segh.type)
+        {
+          case AS_SEQUENCE:
+          case AS_SET:
+            break ;
 
-            case AS_CONFED_SEQUENCE:
-            case AS_CONFED_SET:
-              if (!as4_path)
-                break ;
+          case AS_CONFED_SEQUENCE:
+          case AS_CONFED_SET:
+            if (!as4_path)
+              break ;
               /* RFC4893 3: "invalid for the AS4_PATH attribute"            */
               /* fall through */
 
-            default:    /* reject unknown or invalid AS_PATH segment types  */
-              seg_size = 0 ;
-          } ;
+          default:    /* reject unknown or invalid AS_PATH segment types  */
+            seg_size = 0 ;
         }
-      else
-        seg_size = 0 ;
-
+     
      /* Stop now if segment is not valid (discarding anything collected to date)
       *
       * RFC4271 4.3, Path Attributes, b) AS_PATH:
@@ -738,7 +739,7 @@ assegments_parse (struct stream *s, size_t length, int use32bit, int as4_path)
            */
       if ((seg_size == 0) || (seg_size > length) || (segh.length == 0))
         {
-            assegment_free_all (head);
+          assegment_free_all (head);
           return NULL;
         }
       
index 502f567965a0de85059d4c8da4c926358066c876..570cc3b7335ac692025a5ef285e6cf45acce26f6 100644 (file)
@@ -30,6 +30,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 #include "command.h"
 #include "privs.h"
 #include "linklist.h"
+#include "network.h"
 
 #include "bgpd/bgpd.h"
 #include "bgpd/bgp_fsm.h"
index 1d6b9eef4e29b1366832725a2d80206ab0e07097..ed2cb73eaa3625154266217ca4ff18e7767a1a07 100644 (file)
@@ -2009,7 +2009,7 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
                    * as possible without going beyond the bounds of the entry,
                    * to maximise debug information.
                    */
-                 int ok ;
+                 int ok;
                  memset (&orfp, 0, sizeof (struct orf_prefix));
                  common = *p_pnt++;
                  /* after ++: p_pnt <= p_end */
@@ -2021,11 +2021,11 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
                      break;
                    }
                  ok = ((p_end - p_pnt) >= sizeof(u_int32_t)) ;
-                 if (ok)
+                 if (!ok)
                    {
-                 memcpy (&seq, p_pnt, sizeof (u_int32_t));
-                 p_pnt += sizeof (u_int32_t);
-                 orfp.seq = ntohl (seq);
+                     memcpy (&seq, p_pnt, sizeof (u_int32_t));
+                      p_pnt += sizeof (u_int32_t);
+                      orfp.seq = ntohl (seq);
                    }
                  else
                    p_pnt = p_end ;
@@ -2063,16 +2063,17 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size)
                               inet_ntop (orfp.p.family, &orfp.p.u.prefix, buf, BUFSIZ),
                               orfp.p.prefixlen, orfp.ge, orfp.le,
                               ok ? "" : " MALFORMED");
-
+                  
                  if (ok)
-                 ret = prefix_bgp_orf_set (name, afi, &orfp,
-                                (common & ORF_COMMON_PART_DENY ? 0 : 1 ),
-                                (common & ORF_COMMON_PART_REMOVE ? 0 : 1));
+                   ret = prefix_bgp_orf_set (name, afi, &orfp,
+                                  (common & ORF_COMMON_PART_DENY ? 0 : 1 ),
+                                  (common & ORF_COMMON_PART_REMOVE ? 0 : 1));
 
                  if (!ok || (ret != CMD_SUCCESS))
                    {
                      if (BGP_DEBUG (normal, NORMAL))
-                       zlog_debug ("%s Received misformatted prefixlist ORF. Remove All pfxlist", peer->host);
+                       zlog_debug ("%s Received misformatted prefixlist ORF."
+                                   " Remove All pfxlist", peer->host);
                      prefix_bgp_orf_remove_all (name);
                      break;
                    }