]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-zeromq.c
Handle very large -f files by rejecting them.
[tcpdump] / print-zeromq.c
index 661b9737cb3fc58b9e70b178ae876ed20463748b..a23d98a191275deacde6114c0d46843be2baaa90 100644 (file)
@@ -1,7 +1,4 @@
 /*
- * This file implements decoding of ZeroMQ network protocol(s).
- *
- *
  * Copyright (c) 2013 The TCPDUMP project
  * All rights reserved.
  *
@@ -28,6 +25,8 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+/* \summary: ZeroMQ Message Transport Protocol (ZMTP) printer */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -126,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));