From: Matthias Andree Date: Fri, 17 Jul 2020 19:18:18 +0200 Message-Id: <20200717171818.230371-1-matthias.andree@...68...> In-Reply-To: <20200717170948.227787-1-matthias.andree@...68...> References: <20200717170948.227787-1-matthias.andree@...68...> MIME-Version: 1.0 Subject: [Openvpn-devel] [PATCH] Fix stack buffer overruns in NEXTADDR() macro: List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable To: openvpn-devel@lists.sourceforge.net Cc: Matthias Andree 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 --- 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 b57da5dd..24563ed6 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 =3D ROUNDUP( ((struct sockaddr *)&(u))->sa_len); memmove(cp, &(u= ), l); cp +=3D l; \ + l =3D ((struct sockaddr *)&(u))->sa_len; memmove(cp, &(u), l); cp = +=3D ROUNDUP(l); \ } #define ADVANCE(x, n) (x +=3D ROUNDUP((n)->sa_len)) -- 2.25.4