From 5fde831c580775aa5c1fe3539b06260d994eee10 Mon Sep 17 00:00:00 2001 From: Matthias Andree Date: Fri, 17 Jul 2020 19:18:18 +0200 Subject: [PATCH] Fix stack buffer overruns in NEXTADDR() macro: copy first, then round up the length when adding padding to the advance. Found by: GCC 9.3.0 (FreeBSD) Signed-off-by: Matthias Andree Acked-by: Gert Doering Message-Id: <20200717171818.230371-1-matthias.andree@gmx.de> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20461.html Signed-off-by: Gert Doering --- src/openvpn/route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openvpn/route.c b/src/openvpn/route.c index b57da5dd4..24563ed63 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -3436,7 +3436,7 @@ struct rtmsg { #else /* if defined(TARGET_SOLARIS) */ #define NEXTADDR(w, u) \ if (rtm_addrs & (w)) { \ - l = ROUNDUP( ((struct sockaddr *)&(u))->sa_len); memmove(cp, &(u), l); cp += l; \ + l = ((struct sockaddr *)&(u))->sa_len; memmove(cp, &(u), l); cp += ROUNDUP(l); \ } #define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len)) -- 2.47.2