]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer-htp: close file with TRUNCATE state
authorGiuseppe Longo <glongo@stamus-networks.com>
Mon, 12 Mar 2018 11:41:35 +0000 (12:41 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 7 Aug 2018 11:49:34 +0000 (13:49 +0200)
When a file in TOSERVER direction is being stored and
libhtp or stream depth limit is reached,
it will be closed by HTPCallbackRequest without setting
any flags so the file state will be set to CLOSED
instead of TRUNCATED.

src/app-layer-htp.c

index 604a7b9203764fd07c47bea59ad8023450875972..eff10cb070ef0e2d91bee35e4e8b904507933ce6 100644 (file)
@@ -1760,6 +1760,12 @@ static int HTPCallbackRequestBodyData(htp_tx_data_t *d)
             HtpRequestBodyHandlePUT(hstate, tx_ud, d->tx, (uint8_t *)d->data, (uint32_t)d->len);
         }
 
+    } else {
+        if (tx_ud->tsflags & HTP_FILENAME_SET) {
+            SCLogDebug("closing file that was being stored");
+            (void)HTPFileClose(hstate, NULL, 0, FILE_TRUNCATED, STREAM_TOSERVER);
+            tx_ud->tsflags &= ~HTP_FILENAME_SET;
+        }
     }
 
 end: