]> The Tcpdump Group git mirrors - tcpdump/commitdiff
TCP: Fix an undefined behavior at runtime
authorFrancois-Xavier Le Bail <[email protected]>
Wed, 6 Mar 2019 13:52:14 +0000 (14:52 +0100)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 6 Mar 2019 13:52:14 +0000 (14:52 +0100)
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

index 1b8fb4c4873daafde7d5a55c68cde47049afa26f..d2cb1520868f3e4b719d372e960915b6431a4ff4 100644 (file)
@@ -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("]");
 }