]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
ftp: do not set alproto if one was already found
authorPhilippe Antoine <contact@catenacyber.fr>
Mon, 29 Nov 2021 09:59:10 +0000 (10:59 +0100)
committerVictor Julien <vjulien@oisf.net>
Mon, 13 Dec 2021 11:38:21 +0000 (12:38 +0100)
Ticket: 4857

If a pattern such as GET is seen ine the beginning of the
file transferred over ftp-data, this flow will get recognized
as HTTP, and a HTTP state will be created during parsing.

Thus, we cannot override directly alproto's values

This solves the segfault, but not the logical bug that the flow
should be classified as FTP-DATA instead of HTTP

src/app-layer-expectation.c

index 06c74f263c05bb75d38f1147778b49daaba66970..1f11d13f77950e10bd25205f724d6b8fc88b53f4 100644 (file)
@@ -324,8 +324,12 @@ AppProto AppLayerExpectationHandle(Flow *f, uint8_t flags)
         if ((exp->direction & flags) && ((exp->sp == 0) || (exp->sp == f->sp)) &&
                 ((exp->dp == 0) || (exp->dp == f->dp))) {
             alproto = exp->alproto;
-            f->alproto_ts = alproto;
-            f->alproto_tc = alproto;
+            if (f->alproto_ts == ALPROTO_UNKNOWN) {
+                f->alproto_ts = alproto;
+            }
+            if (f->alproto_tc == ALPROTO_UNKNOWN) {
+                f->alproto_tc = alproto;
+            }
             void *fdata = FlowGetStorageById(f, g_flow_expectation_id);
             if (fdata) {
                 /* We already have an expectation so let's clean this one */