filestore: store chunks in packet direction

Storing too early can lead to files being considered TRUNCATED if the
TCP state is not yet CLOSED when logging is triggered. This has been
observed with FTP-DATA and might also be an issue with simple HTTP.
pull/6324/head
Victor Julien 4 years ago
parent c78f5ac316
commit ca124b033e

@ -225,18 +225,20 @@ static TmEcode OutputFiledataLog(ThreadVars *tv, Packet *p, void *thread_data)
SCReturnInt(TM_ECODE_OK);
}
const bool file_close_ts = ((p->flags & PKT_PSEUDO_STREAM_END) &&
(p->flowflags & FLOW_PKT_TOSERVER));
const bool file_close_tc = ((p->flags & PKT_PSEUDO_STREAM_END) &&
(p->flowflags & FLOW_PKT_TOCLIENT));
const bool file_trunc = StreamTcpReassembleDepthReached(p);
FileContainer *ffc_ts = AppLayerParserGetFiles(f, STREAM_TOSERVER);
FileContainer *ffc_tc = AppLayerParserGetFiles(f, STREAM_TOCLIENT);
SCLogDebug("ffc_ts %p", ffc_ts);
OutputFiledataLogFfc(tv, op_thread_data, p, ffc_ts, STREAM_TOSERVER, file_close_ts, file_trunc, STREAM_TOSERVER);
SCLogDebug("ffc_tc %p", ffc_tc);
OutputFiledataLogFfc(tv, op_thread_data, p, ffc_tc, STREAM_TOCLIENT, file_close_tc, file_trunc, STREAM_TOCLIENT);
if (p->flowflags & FLOW_PKT_TOSERVER) {
const bool file_close_ts = ((p->flags & PKT_PSEUDO_STREAM_END));
FileContainer *ffc_ts = AppLayerParserGetFiles(f, STREAM_TOSERVER);
SCLogDebug("ffc_ts %p", ffc_ts);
OutputFiledataLogFfc(tv, op_thread_data, p, ffc_ts, STREAM_TOSERVER, file_close_ts,
file_trunc, STREAM_TOSERVER);
} else {
const bool file_close_tc = ((p->flags & PKT_PSEUDO_STREAM_END));
FileContainer *ffc_tc = AppLayerParserGetFiles(f, STREAM_TOCLIENT);
SCLogDebug("ffc_tc %p", ffc_tc);
OutputFiledataLogFfc(tv, op_thread_data, p, ffc_tc, STREAM_TOCLIENT, file_close_tc,
file_trunc, STREAM_TOCLIENT);
}
return TM_ECODE_OK;
}

Loading…
Cancel
Save