From c97c3571a009ee9f80b04880c721be012f458db5 Mon Sep 17 00:00:00 2001 From: Francois-Xavier Le Bail Date: Wed, 6 Mar 2019 14:52:14 +0100 Subject: [PATCH] TCP: Fix an undefined behavior at runtime The error was: print-tcp.c:831:22: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'u_int' (aka 'unsigned int') --- print-tcp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/print-tcp.c b/print-tcp.c index 1b8fb4c4..d2cb1520 100644 --- a/print-tcp.c +++ b/print-tcp.c @@ -828,10 +828,11 @@ print_tcp_rst_data(netdissect_options *ndo, ND_PRINT("+"); /* indicate we truncate */ } ND_PRINT(" "); - while (length-- && sp < ndo->ndo_snapend) { + while (length && sp < ndo->ndo_snapend) { c = EXTRACT_U_1(sp); sp++; fn_print_char(ndo, c); + length--; } ND_PRINT("]"); } -- 2.39.5