[Openvpn-devel,v2,1/2] Fix check if iface name is set

Message ID 20190815121053.18433-1-arne@rfc2549.org
State Accepted
Headers show
Series [Openvpn-devel,v2,1/2] Fix check if iface name is set | expand

Commit Message

Arne Schwabe Aug. 15, 2019, 2:10 a.m. UTC
Clang/Android complained

 warning: address of array 'rgi6->iface' will always evaluate to 'true' [-Wpointer-bool-conversion]
          if (rgi6->iface)

iface is a char[16]; So its pointer is always true.

we do a CLEAR(rgi6) always before setting this struct and strcpy the
name into iface. So using strlen instead of checking for the pointer
should be the right fix.

Patch V2: use if(strlen > 0) instead of if(strlen)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
---
 src/openvpn/route.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Antonio Quartulli Aug. 15, 2019, 2:11 a.m. UTC | #1
Hi,

On 15/08/2019 14:10, Arne Schwabe wrote:
> Clang/Android complained
> 
>  warning: address of array 'rgi6->iface' will always evaluate to 'true' [-Wpointer-bool-conversion]
>           if (rgi6->iface)
> 
> iface is a char[16]; So its pointer is always true.
> 
> we do a CLEAR(rgi6) always before setting this struct and strcpy the
> name into iface. So using strlen instead of checking for the pointer
> should be the right fix.
> 
> Patch V2: use if(strlen > 0) instead of if(strlen)
> 
> Signed-off-by: Arne Schwabe <arne@rfc2549.org>

Acked-by: Antonio Quartulli <a@unstable.cc>
Gert Doering Aug. 15, 2019, 2:40 a.m. UTC | #2
Your patch has been applied to the master branch.

commit ac4ceada14b9cb8d1a6180a2e1e07d81af8e34f6
Author: Arne Schwabe
Date:   Thu Aug 15 14:10:52 2019 +0200

     Fix check if iface name is set

     Signed-off-by: Arne Schwabe <arne@rfc2549.org>
     Acked-by: Antonio Quartulli <antonio@openvpn.net>
     Message-Id: <20190815121053.18433-1-arne@rfc2549.org>
     URL: https://www.mail-archive.com/search?l=mid&q=20190815121053.18433-1-arne@rfc2549.org
     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 3035fa89..1b5eacea 100644
--- a/src/openvpn/route.c
+++ b/src/openvpn/route.c
@@ -3350,7 +3350,7 @@  get_default_gateway_ipv6(struct route_ipv6_gateway_info *rgi6,
             rgi6->flags |= RGI_ADDR_DEFINED;
         }
 
-        if (rgi6->iface)
+        if (strlen(rgi6->iface) > 0)
         {
             rgi6->flags |= RGI_IFACE_DEFINED;
         }