]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-lisp.c
CHANGES: Add/move change(s) backported to 4.99
[tcpdump] / print-lisp.c
index 920bfceb1ea1784a5ca7dbdcf2ca281158d10199..da131226579765cd44548515c98dea7cd91c55cb 100644 (file)
  *  +-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  */
 
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include "netdissect-stdinc.h"
 #include "netdissect.h"
-#include <string.h>
-#include <stdlib.h>
 
 #include "ip.h"
 #include "ip6.h"
@@ -131,12 +127,12 @@ enum {
 };
 
 static const struct tok lisp_type [] = {
-       { 0, "LISP-Reserved"                    },
-       { 1, "LISP-Map-Request"                 },
-       { 2, "LISP-Map-Reply"                   },
-       { 3, "LISP-Map-Register"                },
-       { 4, "LISP-Map-Notify"                  },
-       { 8, "LISP-Encapsulated-Contol-Message" },
+       { 0, "LISP-Reserved"                     },
+       { 1, "LISP-Map-Request"                  },
+       { 2, "LISP-Map-Reply"                    },
+       { 3, "LISP-Map-Register"                 },
+       { 4, "LISP-Map-Notify"                   },
+       { 8, "LISP-Encapsulated-Control-Message" },
        { 0, NULL }
 };
 
@@ -285,8 +281,8 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
                goto invalid;
 
        /* Print all the EID records */
-       while ((length > packet_offset) && (record_count--)) {
-
+       while ((length > packet_offset) && (record_count != 0)) {
+               record_count--;
                ND_TCHECK_LEN(packet_iterator + packet_offset,
                              MAP_REGISTER_EID_LEN);
                ND_PRINT("\n");
@@ -328,7 +324,8 @@ lisp_print(netdissect_options *ndo, const u_char *bp, u_int length)
 
                ND_PRINT(" %u locator(s)", loc_count);
 
-               while (loc_count--) {
+               while (loc_count != 0) {
+                       loc_count--;
                        ND_TCHECK_LEN(packet_iterator + packet_offset,
                                      MAP_REGISTER_LOC_LEN);
                        lisp_loc = (const lisp_map_register_loc *) (packet_iterator + packet_offset);