]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-zeromq.c
change make check to work with POSIX shell
[tcpdump] / print-zeromq.c
index e07f8c6904f5b890e5c03644fced36d96d289f28..a23d98a191275deacde6114c0d46843be2baaa90 100644 (file)
@@ -125,8 +125,15 @@ zmtp1_print_frame(netdissect_options *ndo, const u_char *cp, const u_char *ep)
                }
        }
 
-       ND_TCHECK2(*cp, header_len + body_len_declared); /* Next frame within the buffer ? */
-       return cp + header_len + body_len_declared;
+       /*
+        * Do not advance cp by the sum of header_len and body_len_declared
+        * before each offset has successfully passed ND_TCHECK2() as the
+        * sum can roll over (9 + 0xfffffffffffffff7 = 0) and cause an
+        * infinite loop.
+        */
+       cp += header_len;
+       ND_TCHECK2(*cp, body_len_declared); /* Next frame within the buffer ? */
+       return cp + body_len_declared;
 
 trunc:
        ND_PRINT((ndo, "%s", tstr));