]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
files: open/log debug validation bugon
authorVictor Julien <vjulien@oisf.net>
Thu, 24 Mar 2022 15:53:31 +0000 (16:53 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 29 Mar 2022 05:57:17 +0000 (07:57 +0200)
Meant to find more cases where there is a mismatch.

src/output-file.c

index c2a70275401a363600f642140840b4227b68d5e5..832e2e9923044f1b4d653b2ecb4162b9b45bfe69 100644 (file)
@@ -96,11 +96,14 @@ int OutputRegisterFileLogger(LoggerId id, const char *name, FileLogger LogFunc,
 
 static void CloseFile(const Packet *p, Flow *f, File *file)
 {
+    DEBUG_VALIDATE_BUG_ON((file->flags & FILE_LOGGED) != 0);
     void *txv = AppLayerParserGetTx(p->proto, f->alproto, f->alstate, file->txid);
     if (txv) {
         AppLayerTxData *txd = AppLayerParserGetTxData(p->proto, f->alproto, txv);
-        if (txd)
+        if (txd) {
             txd->files_logged++;
+            DEBUG_VALIDATE_BUG_ON(txd->files_logged > txd->files_opened);
+        }
     }
     file->flags |= FILE_LOGGED;
 }