]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Fix stack buffer overruns in NEXTADDR() macro:
authorMatthias Andree <matthias.andree@gmx.de>
Fri, 17 Jul 2020 17:18:18 +0000 (19:18 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 27 Jul 2020 09:06:02 +0000 (11:06 +0200)
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 <matthias.andree@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
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 <gert@greenie.muc.de>
src/openvpn/route.c

index b57da5dd4992bc1bce40486f00dee71fd97a896e..24563ed63520d0e1f8132cacf39452b8eee061ad 100644 (file)
@@ -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))