Control: tag -1 +patch

Although I believe sendmail is functioning as designed and documented,
this bug makes it clear that milters expect and depend on several
sendmail macros in the milter_envrpct() stage. The macros which are set
and updated by initsys() can easily be made available by simply
reordering the calls, as implemented in the attached patch.

This improves the milter API by making the macros consistent between the
first and subsequent milter_envrpct() calls for an envelope.


Bjørn
From a31dd4ba69b14e92e3920020efa59b4ae3ca26af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= <bj...@mork.no>
Date: Tue, 21 Jan 2020 13:04:55 +0100
Subject: [PATCH] milter: update macros before calling milter_envrcpt
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Bjørn Mork <bj...@mork.no>
---
 sendmail/srvrsmtp.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sendmail/srvrsmtp.c b/sendmail/srvrsmtp.c
index b05348d4b2e2..0526205b7627 100644
--- a/sendmail/srvrsmtp.c
+++ b/sendmail/srvrsmtp.c
@@ -3059,6 +3059,10 @@ smtp(nullserver, d_flags, e)
 					}
 				}
 
+				/* make macros available for milter_envrcpt() */
+				if (smtp.sm_nrcpts == 0)
+					initsys(e);
+
 				response = milter_envrcpt(args, e, &state,
 							Errors > 0);
 				milter_cmd_done = true;
@@ -3070,8 +3074,6 @@ smtp(nullserver, d_flags, e)
 			e->e_to = a->q_paddr;
 			if (!(Errors > 0) && !QS_IS_BADADDR(a->q_state))
 			{
-				if (smtp.sm_nrcpts == 0)
-					initsys(e);
 				message("250 2.1.5 Recipient ok%s",
 					QS_IS_QUEUEUP(a->q_state) ?
 						" (will queue)" : "");
-- 
2.20.1

Attachment: signature.asc
Description: PGP signature

Reply via email to