Index | Thread | Search

From:
Philipp <philipp+openbsd@bureaucracy.de>
Subject:
smtpd: correct remove return-path on enqueue
To:
tech@openbsd.org
Date:
Sat, 04 Jan 2025 08:11:48 +0100

Download raw body.

Thread
Hi

When the sendmail binary is used to enqueue a mail the return-path field
is be removed. This is not correct implemented. When the field is foldet
only the first line of the field is removed. A patch fixing the bug
is attached.

Philipp

diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c
index 0dc0ffae1a6..fe49a2860cb 100644
--- a/usr.sbin/smtpd/enqueue.c
+++ b/usr.sbin/smtpd/enqueue.c
@@ -180,6 +180,7 @@ enqueue(int argc, char *argv[], FILE *ofp)
 	ssize_t			 len;
 	char			*line;
 	int			 inheaders = 1;
+	int			 remove_rpath = 0;
 	int			 save_argc;
 	char			**save_argv;
 	int			 no_getlogin = 0;
@@ -401,10 +402,15 @@ enqueue(int argc, char *argv[], FILE *ofp)
 		line = buf;
 
 		if (inheaders) {
+			if (remove_rpath && (line[0] == ' ' || line[0] == '\t'))
+				continue;
 			if (strncasecmp("from ", line, 5) == 0)
 				continue;
-			if (strncasecmp("return-path: ", line, 13) == 0)
+			if (strncasecmp("return-path: ", line, 13) == 0) {
+				remove_rpath = 1;
 				continue;
+			}
+			remove_rpath = 0;
 		}
 
 		if (msg.saw_content_transfer_encoding || msg.noheader ||