From 2454682ee3e534fdacd5897e5f911d93060ece87 Mon Sep 17 00:00:00 2001 From: aafbsd <45147422+aafbsd@users.noreply.github.com> Date: Sun, 22 Dec 2024 08:35:03 +0000 Subject: [PATCH] Fix: do not use strlcpy() if buffers overlap This resulted in messed up d= tags on FreeBSD. The result was that mails using the SubDomains feature were signed improperly. --- opendkim/opendkim.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/opendkim/opendkim.c b/opendkim/opendkim.c index 803f37b0..eaa1c086 100644 --- a/opendkim/opendkim.c +++ b/opendkim/opendkim.c @@ -12303,8 +12303,10 @@ mlfi_eoh(SMFICTX *ctx) if (domainok) { - strlcpy((char *) dfc->mctx_domain, p, - sizeof dfc->mctx_domain); + // We must not use strlcpy() here since + // src and dst overlap. + char* p2 = dfc->mctx_domain; + while( (*p2++ = *p++) ); break; } }