]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http: complete multipart data on open
authorPhilippe Antoine <pantoine@oisf.net>
Wed, 17 May 2023 16:15:02 +0000 (18:15 +0200)
committerVictor Julien <vjulien@oisf.net>
Mon, 5 Jun 2023 09:17:38 +0000 (11:17 +0200)
Take as much as we can when opening, by making sure that the
boundary is not present

src/app-layer-htp.c

index 3b8baae4b65a38569857adf9cbc1709f7d2f2913..b2c915d9342d610fe302b041359c934cb7f726a1 100644 (file)
@@ -1604,6 +1604,16 @@ static int HtpRequestBodyHandleMultipart(HtpState *hstate, HtpTxUserData *htud,
 
                     if (filedata_len >= (uint32_t)(expected_boundary_len + 2)) {
                         filedata_len -= (expected_boundary_len + 2 - 1);
+                        // take as much as we can until start of boundary
+                        for (size_t nb = 0; nb < (size_t)expected_boundary_len + 1; nb++) {
+                            if (filedata[filedata_len] == '\r') {
+                                if (nb == expected_boundary_len ||
+                                        filedata[filedata_len + 1] == '\n') {
+                                    break;
+                                }
+                            }
+                            filedata_len++;
+                        }
                         SCLogDebug("opening file with partial data");
                     } else {
                         filedata = NULL;