From fc38013975ab8875863e23efda97eaecb7ff7a09 Mon Sep 17 00:00:00 2001 From: Giuseppe Longo Date: Mon, 12 Mar 2018 12:41:35 +0100 Subject: [PATCH] app-layer-htp: close file with TRUNCATE state 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/app-layer-htp.c b/src/app-layer-htp.c index 604a7b9203..eff10cb070 100644 --- a/src/app-layer-htp.c +++ b/src/app-layer-htp.c @@ -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: