From 8a419c96d659fff282563914fe821bf195894da7 Mon Sep 17 00:00:00 2001 From: Shawn Iverson Date: Sun, 3 Mar 2019 08:54:37 -0500 Subject: [PATCH] Check for empty queue id (#368) --- common/usr/sbin/MSMilter | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/common/usr/sbin/MSMilter b/common/usr/sbin/MSMilter index 64036c3..907f4e8 100644 --- a/common/usr/sbin/MSMilter +++ b/common/usr/sbin/MSMilter @@ -1,7 +1,7 @@ #!/usr/bin/perl -U -I /usr/share/MailScanner/perl -# (c) 2018 MailScanner Project -# Version 1.3 +# (c) 2019 MailScanner Project +# Version 1.4 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -268,7 +268,12 @@ sub header_callback if (${$message_ref} =~ /SMTP\sid\s$/ ) { if (defined($symbols->{'L'}) && defined($symbols->{'L'}->{'i'}) ) { $id = $symbols->{'L'}->{'i'}; - MailScanner::Log::DebugLog("Postfix ID captured: $id"); + if ( $id ne '' ) { + MailScanner::Log::DebugLog("Postfix ID captured: $id"); + } else { + $id = smtp_id; + MailScanner::Log::DebugLog("Postfix id empty, generated one instead: $id"); + } } else { $id = smtp_id; MailScanner::Log::DebugLog("Unable to capture real postfix id, generated one instead: $id"); @@ -339,6 +344,13 @@ sub eoh_callback } } + if ( $id eq '' ) { + # Missing a queue id, header_callback possibly skipped, reject + MailScanner::Log::WarnLog("Postfix queue id is missing"); + Sendmail::PMilter::SMFIS_TEMPFAIL; + return; + } + # Write header to file my $queuehandle = new FileHandle; my $incoming = MailScanner::Config::Value('inqueuedir');