Skip to contentSkip to conversation

route.c: pass the right parameter to IN6_IS_ADDR_UNSPECIFIED

PATCH In review Antonio Quartulli 3 participants 3 messages Aug 26, 2021 – Aug 28, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 route.c: pass the right parameter to IN6_IS_ADDR_UNSPECIFIED

IN6_IS_ADDR_UNSPECIFIED on most systems is defined as a macro that expects a struct in6_addr* argument.

In one instance we are passing the right address but using a wrong type. Fix this invocation by properly passing the right pointer.

This issue might become more critical on systems implementing IN6_IS_ADDR_UNSPECIFIED as a function rather than a macro.

---
 src/openvpn/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/openvpn/route.c +1 -1
index 2905e432..fd1125ef 100644
@@ -3360,7 +3360,7 @@ get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
     if (net_route_v6_best_gw(ctx, dest, &rgi6->gateway.addr_ipv6,
                              rgi6->iface) == 0)
     {
-        if (!IN6_IS_ADDR_UNSPECIFIED(rgi6->gateway.addr_ipv6.s6_addr))
+        if (!IN6_IS_ADDR_UNSPECIFIED(&rgi6->gateway.addr_ipv6))
         {
             rgi6->flags |= RGI_ADDR_DEFINED;
         }
Signature · 1 line
2.31.1
Acked-by on v1 1/1
#1 lore raw

Am 26.08.21 um 08:17 schrieb Antonio Quartulli:

Quoted 8 lines

IN6_IS_ADDR_UNSPECIFIED on most systems is defined as a macro that expects a struct in6_addr* argument.

In one instance we are passing the right address but using a wrong type. Fix this invocation by properly passing the right pointer.

This issue might become more critical on systems implementing IN6_IS_ADDR_UNSPECIFIED as a function rather than a macro.

This happens if you try to compile openvpn with the Android NDK but without TARGET_ANDROID but with TARGET_LINUX.

#define IN6_IS_ADDR_UNSPECIFIED(a) \
((((a)->s6_addr32[0]) == 0) && \
(((a)->s6_addr32[1]) == 0) && \
(((a)->s6_addr32[2]) == 0) && \
(((a)->s6_addr32[3]) == 0))

So you get

/Users/arne/oss/android-sdk-macosx/ndk/23.0.7599858/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/netinet/in6.h:38:9:
note: expanded from macro 'IN6_IS_ADDR_UNSPECIFIED'

     (((a)->s6_addr32[1]) == 0) && \
       ~~~^ ~~~~~~~~~

/Users/arne/software/icsopenvpn/main/src/main/cpp/openvpn/src/openvpn/route.c:3375:14:
error: member reference base type '__u8' (aka 'unsigned char') is not a structure or union

          if (!IN6_IS_ADDR_UNSPECIFIED(rgi6->gateway.addr_ipv6.s6_addr))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#2 lore raw
In reply to Antonio Quartulli

I have not tested this beyond "openvpn --show-gateway", and that one still works :-) - also, we've discussed this on IRC before.

Your patch has been applied to the master and release/2.5 branch (bugfix).

2.4 does not contain the offending code.

commit aa0e44e235f7bee0e12707b6899d00bad85195fc (master) commit 477781335cbca1aec69a372cbc18bf086155eea1 (release/2.5)

Author: Antonio Quartulli
Date:   Thu Aug 26 08:17:25 2021 +0200
     route.c: pass the right parameter to IN6_IS_ADDR_UNSPECIFIED

     Signed-off-by: Antonio Quartulli <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg22767.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering