X-Git-Url: https://git.tcpdump.org/tcpdump/blobdiff_plain/795239658b796cc41200e86266b92729e277d99b..ebb51ef0e725737ca8c1d618da6527a58660d2bf:/print-zeromq.c diff --git a/print-zeromq.c b/print-zeromq.c index 661b9737..a23d98a1 100644 --- a/print-zeromq.c +++ b/print-zeromq.c @@ -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));