Index | Thread | Search

From:
"Omar Polo" <op@omarpolo.com>
Subject:
smtpd: use memcpy() in xmemdup
To:
tech@openbsd.org
Date:
Sun, 15 Mar 2026 17:19:47 +0100

Download raw body.

Thread
Unsure why it's memmove() since the two pointers cannot overlap by construction.
xmemdup() was added by eric@ back in 2012, and it seems he took the existing
memmove that used to be in IMSG_BATCH_APPEND handling in mta.c, which was also
"wrong", since a memcpy() would suffice.  I haven't dig earlier in the history.
(c.f. 591e1804eb on src.git or mta.c revision 1.141..1.142)

ok?

diff /home/op/w/smtpd
path + /home/op/w/smtpd
commit - 6965f4adac1ec8b9b9fcb3516ed56fae271049dc
blob - 948bb06e9a1ef43ab28919e45d8f95703351ca71
file + util.c
--- util.c
+++ util.c
@@ -95,7 +95,7 @@ xmemdup(const void *ptr, size_t size)
 	if ((r = malloc(size)) == NULL)
 		fatal("malloc");
 
-	memmove(r, ptr, size);
+	memcpy(r, ptr, size);
 
 	return (r);
 }