summaryrefslogtreecommitdiff
path: root/print-tcp.c
diff options
context:
space:
mode:
authorFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2019-03-06 14:52:14 +0100
committerFrancois-Xavier Le Bail <devel.fx.lebail@orange.fr>2019-03-06 14:52:14 +0100
commitc97c3571a009ee9f80b04880c721be012f458db5 (patch)
tree020566df2e40e3b2572906111ec190b6eb810923 /print-tcp.c
parent457a4acb890dae45afb3f961a0c8e19c6bfea931 (diff)
downloadtcpdump-c97c3571a009ee9f80b04880c721be012f458db5.tar.gz
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')
Diffstat (limited to 'print-tcp.c')
-rw-r--r--print-tcp.c3
1 files changed, 2 insertions, 1 deletions
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("]");
}