From 3e47678e1f507806ce2b0b39c6423d6c8bfc4873 Mon Sep 17 00:00:00 2001 From: millert Date: Thu, 20 Oct 2022 01:16:04 +0000 Subject: [PATCH] Display the correct recipient in a Received: header with one recipient. If multiple recipients are specified but only one is valid, use the first entry in the recipient list for the Received: header, not the value from the last "RCPT TO:" command (which could be invalid). From Chris Waddey --- usr.sbin/smtpd/smtp_session.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/usr.sbin/smtpd/smtp_session.c b/usr.sbin/smtpd/smtp_session.c index 13756932208..72e13e8fd8d 100644 --- a/usr.sbin/smtpd/smtp_session.c +++ b/usr.sbin/smtpd/smtp_session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: smtp_session.c,v 1.432 2021/07/01 07:42:16 eric Exp $ */ +/* $OpenBSD: smtp_session.c,v 1.433 2022/10/20 01:16:04 millert Exp $ */ /* * Copyright (c) 2008 Gilles Chehade @@ -2732,6 +2732,7 @@ static void smtp_message_begin(struct smtp_tx *tx) { struct smtp_session *s; + struct smtp_rcpt *rcpt; int (*m_printf)(struct smtp_tx *, const char *, ...); m_printf = smtp_message_printf; @@ -2781,9 +2782,10 @@ smtp_message_begin(struct smtp_tx *tx) } if (tx->rcptcount == 1) { + rcpt = TAILQ_FIRST(&tx->rcpts); m_printf(tx, "\n\tfor <%s@%s>", - tx->evp.rcpt.user, - tx->evp.rcpt.domain); + rcpt->maddr.user, + rcpt->maddr.domain); } m_printf(tx, ";\n\t%s\n", time_to_text(time(&tx->time))); -- 2.20.1