From 7c428ca19a8df6b9630734eafce1132f457be951 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 (cherry picked from commit 5fde831c580775aa5c1fe3539b06260d994eee10) --- 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 4199da3b5..c66217adb 100644 --- a/src/openvpn/route.c +++ b/src/openvpn/route.c @@ -3575,7 +3575,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.3