]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: don't wrap around on port 65535
authorJason Ish <jason.ish@oisf.net>
Tue, 9 Aug 2022 18:21:31 +0000 (12:21 -0600)
committerVictor Julien <vjulien@oisf.net>
Thu, 18 Aug 2022 11:29:44 +0000 (13:29 +0200)
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

index 468cfba9048a3ffc8e61a445839c9276ee3267ac..3971291245cda300805ddf7a8434dd47bac77ecf 100644 (file)
@@ -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;
     }