Skip to contentSkip to conversation

Fix stack overflow in OpenSolaris NEXTADDR()

PATCH In review Gert Doering 2 participants 3 messages Aug 13, 2020 – Aug 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 src/openvpn/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/route.c +1 -1
index 24563ed6..f127a90a 100644
@@ -3429,7 +3429,7 @@ struct rtmsg {
 #if defined(TARGET_SOLARIS)
 #define NEXTADDR(w, u) \
     if (rtm_addrs & (w)) { \
-        l = ROUNDUP(sizeof(u)); memmove(cp, &(u), l); cp += l; \
+        l = sizeof(u); memmove(cp, &(u), l); cp += ROUNDUP(l); \
     }
 
 #define ADVANCE(x, n) (x += ROUNDUP(sizeof(struct sockaddr_in)))
Signature · 1 line
2.23.0
Acked-by on v1 1/1
#1 lore raw

Am 13.08.20 um 12:13 schrieb Gert Doering:

Quoted 17 lines

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.

---
 src/openvpn/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/route.c +0 -0
index 24563ed6..f127a90a 100644

src/openvpn/route.c struct rtmsg { · line 3435

Quoted 8 lines
src/openvpn/route.c +1 -1
@@ -3429,7 +3429,7 @@ struct rtmsg {
 #if defined(TARGET_SOLARIS)
 #define NEXTADDR(w, u) \
     if (rtm_addrs & (w)) { \
-        l = ROUNDUP(sizeof(u)); memmove(cp, &(u), l); cp += l; \
+        l = sizeof(u); memmove(cp, &(u), l); cp += ROUNDUP(l); \
     }
 
 #define ADVANCE(x, n) (x += ROUNDUP(sizeof(struct sockaddr_in)))
#2 lore raw
In reply to Gert Doering

Patch has been applied to the master, 2.5 and 2.4 branch (bugfix).

commit 7e65483d1227adfb855844467e4d30894ffc355d (master) commit 7b9dd9b091a3cad126642314ea945bafa4e91481 (release/2.5) commit 5f88c077de8da4a4c5369ae67f5815e4abc50edc (release/2.4)

Author: Gert Doering
Date:   Thu Aug 13 12:13:01 2020 +0200
     Fix stack overflow in OpenSolaris NEXTADDR()

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg20731.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering