git: 0b80bf9edb19 - stable/14 - udp: Prefer memcpy() over bcopy()

From: Zhenlei Huang <zlei_at_FreeBSD.org>
Date: Fri, 06 Dec 2024 13:52:37 UTC
The branch stable/14 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=0b80bf9edb199ca35dae25241e2dc38bd7e84cb9

commit 0b80bf9edb199ca35dae25241e2dc38bd7e84cb9
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2024-11-28 10:04:23 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2024-12-06 13:51:42 +0000

    udp: Prefer memcpy() over bcopy()
    
    The variable b[] is on the stack, thus cannot overlap with ipov, which
    points to the heap area, so prefer memcpy() over memmove(), aka bcopy().
    
    No functional change intended.
    
    Reviewed by:    cc, rrs, cy, #transport, #network
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D47713
    
    (cherry picked from commit 949190c5afbc677c53b5d96354b52256923a11d1)
---
 sys/netinet/udp_usrreq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c
index 7329600ecc79..47f7eb65f119 100644
--- a/sys/netinet/udp_usrreq.c
+++ b/sys/netinet/udp_usrreq.c
@@ -546,12 +546,12 @@ udp_input(struct mbuf **mp, int *offp, int proto)
 			char b[offsetof(struct ipovly, ih_src)];
 			struct ipovly *ipov = (struct ipovly *)ip;
 
-			bcopy(ipov, b, sizeof(b));
+			memcpy(b, ipov, sizeof(b));
 			bzero(ipov, sizeof(ipov->ih_x1));
 			ipov->ih_len = (proto == IPPROTO_UDP) ?
 			    uh->uh_ulen : htons(ip_len);
 			uh_sum = in_cksum(m, len + sizeof (struct ip));
-			bcopy(b, ipov, sizeof(b));
+			memcpy(ipov, b, sizeof(b));
 		}
 		if (uh_sum) {
 			UDPSTAT_INC(udps_badsum);