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.

(cherry picked from commit ca124b033e)
pull/6379/head
Victor Julien 6 years ago committed by Shivani Bhardwaj
parent 717c6b021e
commit 00e6f881e4

@ -239,18 +239,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 if (p->flowflags & FLOW_PKT_TOCLIENT) {
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