From bc357c6ca1be3338abe2fc4e0ca4e47dfe10f99d Mon Sep 17 00:00:00 2001 From: Arne Welzel Date: Tue, 23 Jan 2024 15:38:24 +0100 Subject: [PATCH] SMTP: Reset ContentLineAnalyzer plain delivery on EndData() When resetting the BDAT state, we also need to switch the ContentLine analyzer back into line mode, otherwise we're feeding plain delivery data through ProcessLine(), possibly violating some assumptions about null termination. Do it for both ContentLineAnalyzers - only one of them will be in plain delivery mode anyhow, but we don't keep state which one it was. --- src/analyzer/protocol/smtp/SMTP.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/analyzer/protocol/smtp/SMTP.cc b/src/analyzer/protocol/smtp/SMTP.cc index 185a3b46bd..e717742cdc 100644 --- a/src/analyzer/protocol/smtp/SMTP.cc +++ b/src/analyzer/protocol/smtp/SMTP.cc @@ -899,6 +899,12 @@ void SMTP_Analyzer::BeginData(bool orig, detail::SMTP_State new_state) { void SMTP_Analyzer::EndData() { if ( bdat ) { + if ( bdat->RemainingChunkSize() > 0 ) { + Weird("smtp_bdat_remaining_at_end_data"); + cl_orig->SetPlainDelivery(0); + cl_resp->SetPlainDelivery(0); + } + bdat->Done(); bdat.reset(); }