]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output/filedata: trunc file in output again
authorVictor Julien <vjulien@oisf.net>
Sun, 22 Jan 2023 07:29:43 +0000 (08:29 +0100)
committerVictor Julien <vjulien@oisf.net>
Mon, 23 Jan 2023 09:33:32 +0000 (10:33 +0100)
src/output-filedata.c
src/output-filedata.h
src/output-tx.c

index 6d8a5e3ed06de38dedbf3ff1f990d833fa48b3a0..a9890769a7b3b25dcdb7142a70fa49fc36fdb707 100644 (file)
@@ -127,13 +127,13 @@ static void CloseFile(const Packet *p, Flow *f, File *file, void *txv)
 }
 
 void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Packet *p,
-        FileContainer *ffc, void *txv, const uint64_t tx_id, AppLayerTxData *txd,
+        AppLayerGetFileState files, void *txv, const uint64_t tx_id, AppLayerTxData *txd,
         const uint8_t call_flags, const bool file_close, const bool file_trunc, const uint8_t dir)
 {
-    SCLogDebug("ffc %p", ffc);
+    SCLogDebug("ffc %p", files.fc);
 
     OutputLoggerThreadStore *store = td->store;
-    for (File *ff = ffc->head; ff != NULL; ff = ff->next) {
+    for (File *ff = files.fc->head; ff != NULL; ff = ff->next) {
         FileApplyTxFlags(txd, dir, ff);
         FilePrintFlags(ff);
 
@@ -162,7 +162,7 @@ void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Pa
          * close the logger(s) */
         if (FileDataSize(ff) == ff->content_stored && (file_trunc || file_close)) {
             if (ff->state < FILE_STATE_CLOSED) {
-                ff->state = FILE_STATE_TRUNCATED;
+                FileCloseFilePtr(ff, files.cfg, NULL, 0, FILE_TRUNCATED);
             }
             file_flags |= OUTPUT_FILEDATA_FLAG_CLOSE;
             CallLoggers(tv, store, p, ff, txv, tx_id, NULL, 0, file_flags, dir);
@@ -173,7 +173,7 @@ void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Pa
         /* if file needs to be closed or truncated, inform
          * loggers */
         if ((file_close || file_trunc) && ff->state < FILE_STATE_CLOSED) {
-            ff->state = FILE_STATE_TRUNCATED;
+            FileCloseFilePtr(ff, files.cfg, NULL, 0, FILE_TRUNCATED);
         }
 
         /* tell the logger we're closing up */
index 6d2d5446645d5e309d9c9c47451a85481787d516..58764aa81e0379008970edad9b3a28a8aea397b3 100644 (file)
@@ -42,7 +42,7 @@ TmEcode OutputFiledataLogThreadInit(ThreadVars *tv, OutputFiledataLoggerThreadDa
 TmEcode OutputFiledataLogThreadDeinit(ThreadVars *tv, OutputFiledataLoggerThreadData *thread_data);
 
 void OutputFiledataLogFfc(ThreadVars *tv, OutputFiledataLoggerThreadData *td, Packet *p,
-        FileContainer *ffc, void *txv, const uint64_t tx_id, AppLayerTxData *txd,
+        AppLayerGetFileState files, void *txv, const uint64_t tx_id, AppLayerTxData *txd,
         const uint8_t call_flags, const bool file_close, const bool file_trunc, const uint8_t dir);
 
 /** filedata logger function pointer type */
index 1fd4a1a2a98d05b7fe617be563f09c24daefe9ac..6ddbdd1f62469fa3a33e5b25f2cce825e0a91d25 100644 (file)
@@ -194,8 +194,8 @@ static inline void OutputTxLogFiles(ThreadVars *tv, OutputFileLoggerThreadData *
         SCLogDebug("tx: calling files: ffc %p head %p file_close %d file_trunc %d", ffc, ffc->head,
                 file_close, file_trunc);
         if (filedata_td && txd->files_opened > txd->files_stored)
-            OutputFiledataLogFfc(tv, filedata_td, p, ffc, tx, tx_id, txd, packet_dir, file_close,
-                    file_trunc, packet_dir);
+            OutputFiledataLogFfc(tv, filedata_td, p, app_files, tx, tx_id, txd, packet_dir,
+                    file_close, file_trunc, packet_dir);
         if (file_td && txd->files_opened > txd->files_logged)
             OutputFileLogFfc(
                     tv, file_td, p, ffc, tx, tx_id, txd, file_close, file_trunc, packet_dir);
@@ -208,8 +208,8 @@ static inline void OutputTxLogFiles(ThreadVars *tv, OutputFileLoggerThreadData *
         SCLogDebug("tx: calling for opposing direction files: file_close:%s file_trunc:%s",
                 file_close ? "true" : "false", file_trunc ? "true" : "false");
         if (filedata_td && txd->files_opened > txd->files_stored)
-            OutputFiledataLogFfc(tv, filedata_td, p, ffc_opposing, tx, tx_id, txd, opposing_dir,
-                    file_close, file_trunc, opposing_dir);
+            OutputFiledataLogFfc(tv, filedata_td, p, app_files_opposing, tx, tx_id, txd,
+                    opposing_dir, file_close, file_trunc, opposing_dir);
         if (file_td && txd->files_opened > txd->files_logged)
             OutputFileLogFfc(tv, file_td, p, ffc_opposing, tx, tx_id, txd, file_close, file_trunc,
                     opposing_dir);