[Openvpn-devel] Fix stack overflow in OpenSolaris NEXTADDR()

Message ID 20200813101301.12720-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel] Fix stack overflow in OpenSolaris NEXTADDR() | expand

Commit Message

Gert Doering Aug. 13, 2020, 12:13 a.m. UTC
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>
---
 src/openvpn/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Arne Schwabe Aug. 14, 2020, 12:23 a.m. UTC | #1
Am 13.08.20 um 12:13 schrieb Gert Doering:
> 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>
> ---
>  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 24563ed6..f127a90a 100644
> --- a/src/openvpn/route.c
> +++ b/src/openvpn/route.c
> @@ -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)))
> 

Acked-By: Arne Schwabe <arne@rfc2549.org>
Gert Doering Aug. 14, 2020, 2:40 a.m. UTC | #2
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 <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>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/route.c b/src/openvpn/route.c
index 24563ed6..f127a90a 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -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)))