]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
smtp: register file truncate callback
authorVictor Julien <victor@inliniac.net>
Tue, 28 Oct 2014 09:41:32 +0000 (10:41 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 30 Oct 2014 12:33:54 +0000 (13:33 +0100)
Tag files as truncated from this callback so storing/logging displays
the correct info.

src/app-layer-smtp.c

index 4c414b4ea92e49e03a5d0875fcbb8c6d6eade4a3..51d9730baa95337cc22329c155ec01424d0e30a2 100644 (file)
@@ -1314,6 +1314,16 @@ static FileContainer *SMTPStateGetFiles(void *state, uint8_t direction)
     }
 }
 
+static void SMTPStateTruncate(void *state, uint8_t direction)
+{
+    FileContainer *fc = SMTPStateGetFiles(state, direction);
+    if (fc != NULL) {
+        SCLogDebug("truncating stream, closing files in %s direction (container %p)",
+                direction & STREAM_TOCLIENT ? "STREAM_TOCLIENT" : "STREAM_TOSERVER", fc);
+        FileTruncateAllOpenFiles(fc);
+    }
+}
+
 /**
  * \brief Register the SMTP Protocol parser.
  */
@@ -1351,6 +1361,7 @@ void RegisterSMTPParsers(void)
         AppLayerParserRegisterGetTx(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateGetTx);
         AppLayerParserRegisterGetStateProgressCompletionStatus(IPPROTO_TCP, ALPROTO_SMTP,
                                                                SMTPStateGetAlstateProgressCompletionStatus);
+        AppLayerParserRegisterTruncateFunc(IPPROTO_TCP, ALPROTO_SMTP, SMTPStateTruncate);
     } else {
         SCLogInfo("Parsed disabled for %s protocol. Protocol detection"
                   "still on.", proto_name);