From ddd5f23457555f3583ce718bb10721c6772cb1de Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Wed, 3 Dec 2014 20:27:10 +0100 Subject: [PATCH] Implement a fix from OpenBSD 5.6-stable: backport the correct fix for overlapping memcpy which caused corrupt MACs ok pedro@ --- sys/net/if_ethersubr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index e37066984d1..305b46a0104 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.174 2014/07/12 18:44:22 tedu Exp $ */ +/* $OpenBSD: src/sys/net/if_ethersubr.c,v 1.174.4.1 2014/12/01 17:50:43 tedu Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -673,7 +673,12 @@ ether_input(struct ifnet *ifp0, struct ether_header *eh, struct mbuf *m) goto done; eh_tmp = mtod(m, struct ether_header *); - memcpy(eh_tmp, eh, sizeof(struct ether_header)); + /* + * danger! + * eh_tmp and eh may overlap because eh + * is stolen from the mbuf above. + */ + memmove(eh_tmp, eh, sizeof(struct ether_header)); #ifdef PIPEX if (pipex_enable) { struct pipex_session *session;