Browse code

Fix stack overflow in OpenSolaris NEXTADDR()

Commit 5fde831c5807 fixed NEXTADDR() for all *BSDs and MacOS.

OpenSolaris has to use a slightly different macro due to lack of
sockaddr->sa_len - but it has the same problem, first rounding up,
then memmove()'ing. Switch order.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200813101301.12720-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20731.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 7e65483d1227adfb855844467e4d30894ffc355d)

Gert Doering authored on 2020/08/13 19:13:01
Showing 1 changed files
... ...
@@ -3429,7 +3429,7 @@ struct rtmsg {
3429 3429
 #if defined(TARGET_SOLARIS)
3430 3430
 #define NEXTADDR(w, u) \
3431 3431
     if (rtm_addrs & (w)) { \
3432
-        l = ROUNDUP(sizeof(u)); memmove(cp, &(u), l); cp += l; \
3432
+        l = sizeof(u); memmove(cp, &(u), l); cp += ROUNDUP(l); \
3433 3433
     }
3434 3434
 
3435 3435
 #define ADVANCE(x, n) (x += ROUNDUP(sizeof(struct sockaddr_in)))