From f1f43cba5e16666b34467b7b373659c5aa7b210b Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Tue, 9 Aug 2022 12:21:31 -0600 Subject: [PATCH] app-layer: don't wrap around on port 65535 A port value of 65535 caused the port value to wrap-around to 0 resulting in an infinite loop. Fixes: 53fc70a9a73c ("protodetect: fix int warnings") --- src/app-layer-detect-proto.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app-layer-detect-proto.c b/src/app-layer-detect-proto.c index 468cfba904..3971291245 100644 --- a/src/app-layer-detect-proto.c +++ b/src/app-layer-detect-proto.c @@ -1708,7 +1708,7 @@ void AppLayerProtoDetectPPRegister(uint8_t ipproto, uint16_t port = temp_dp->port; if (port == 0 && temp_dp->port2 != 0) port++; - for ( ; port <= temp_dp->port2; port++) { + for (;;) { AppLayerProtoDetectInsertNewProbingParser(&alpd_ctx.ctx_pp, ipproto, port, @@ -1717,6 +1717,11 @@ void AppLayerProtoDetectPPRegister(uint8_t ipproto, direction, ProbingParser1, ProbingParser2); + if (port == temp_dp->port2) { + break; + } else { + port++; + } } temp_dp = temp_dp->next; }