* \retval -1 error
* \retval -2 not storing files on this flow/tx
*/
-int HTPFileClose(HtpState *s, const uint8_t *data, uint32_t data_len,
+int HTPFileClose(HtpState *s, HtpTxUserData *htud, const uint8_t *data, uint32_t data_len,
uint8_t flags, uint8_t direction)
{
SCEnter();
}
if (s->file_range != NULL) {
- HTPFileCloseHandleRange(files, flags, s->file_range, data, data_len);
+ bool added = HTPFileCloseHandleRange(files, flags, s->file_range, data, data_len);
+ if (added) {
+ htud->tx_data.files_opened++;
+ }
HttpRangeFreeBlock(s->file_range);
s->file_range = NULL;
}
bool HTPFileCloseHandleRange(
FileContainer *, const uint16_t, HttpRangeContainerBlock *, const uint8_t *, uint32_t);
int HTPFileStoreChunk(HtpState *, const uint8_t *, uint32_t, uint8_t);
-int HTPFileClose(HtpState *, const uint8_t *, uint32_t, uint8_t, uint8_t);
+int HTPFileClose(HtpState *, HtpTxUserData *, const uint8_t *, uint32_t, uint8_t, uint8_t);
void HTPFileParserRegisterTests(void);
printf("FILEDATA (final chunk) END: \n");
#endif
if (!(htud->tsflags & HTP_DONTSTORE)) {
- if (HTPFileClose(hstate, filedata, filedata_len, flags,
- STREAM_TOSERVER) == -1)
- {
+ if (HTPFileClose(hstate, htud, filedata, filedata_len, flags, STREAM_TOSERVER) ==
+ -1) {
goto end;
}
}
} else if (result == -2) {
htud->tsflags |= HTP_DONTSTORE;
} else {
- if (HTPFileClose(hstate, NULL, 0, 0, STREAM_TOSERVER) == -1) {
+ if (HTPFileClose(hstate, htud, NULL, 0, 0, STREAM_TOSERVER) == -1) {
goto end;
}
}
} else if (result == -2) {
htud->tsflags |= HTP_DONTSTORE;
} else {
- if (HTPFileClose(hstate, NULL, 0, 0, STREAM_TOSERVER) == -1) {
+ if (HTPFileClose(hstate, htud, NULL, 0, 0, STREAM_TOSERVER) == -1) {
goto end;
}
}
} else {
if (tx_ud->tsflags & HTP_FILENAME_SET) {
SCLogDebug("closing file that was being stored");
- (void)HTPFileClose(hstate, NULL, 0, FILE_TRUNCATED, STREAM_TOSERVER);
+ (void)HTPFileClose(hstate, tx_ud, NULL, 0, FILE_TRUNCATED, STREAM_TOSERVER);
tx_ud->tsflags &= ~HTP_FILENAME_SET;
}
}
} else {
if (tx_ud->tcflags & HTP_FILENAME_SET) {
SCLogDebug("closing file that was being stored");
- (void)HTPFileClose(hstate, NULL, 0, FILE_TRUNCATED, STREAM_TOCLIENT);
+ (void)HTPFileClose(hstate, tx_ud, NULL, 0, FILE_TRUNCATED, STREAM_TOCLIENT);
tx_ud->tcflags &= ~HTP_FILENAME_SET;
}
}
if (htud != NULL) {
if (htud->tsflags & HTP_FILENAME_SET) {
SCLogDebug("closing file that was being stored");
- (void)HTPFileClose(hstate, NULL, 0, 0, STREAM_TOSERVER);
+ (void)HTPFileClose(hstate, htud, NULL, 0, 0, STREAM_TOSERVER);
htud->tsflags &= ~HTP_FILENAME_SET;
if (abs_right_edge < (uint64_t)UINT32_MAX) {
StreamTcpReassemblySetMinInspectDepth(
if (htud != NULL) {
if (htud->tcflags & HTP_FILENAME_SET) {
SCLogDebug("closing file that was being stored");
- (void)HTPFileClose(hstate, NULL, 0, 0, STREAM_TOCLIENT);
+ (void)HTPFileClose(hstate, htud, NULL, 0, 0, STREAM_TOCLIENT);
htud->tcflags &= ~HTP_FILENAME_SET;
}
}