This was originally reported on GH, but never dealt with.
Make sure 'ptr' is always initialized to prevent derefence of null
pointer in case of empty dev string.

While at it, change the if condition to use ptr instead of dev, since
dev is not used anymore in the logic.

Signed-off-by: Antonio Quartulli <a...@unstable.cc>
---
 src/openvpn/tun.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/openvpn/tun.c b/src/openvpn/tun.c
index a17ff50f..44fad06d 100644
--- a/src/openvpn/tun.c
+++ b/src/openvpn/tun.c
@@ -2379,10 +2379,11 @@ open_tun(const char *dev, const char *dev_type, const 
char *dev_node, struct tun
         msg(M_ERR, "Can't open %s", dev_node);
     }
 
+    ptr = dev;
+
     /* get unit number */
-    if (*dev)
+    if (*ptr)
     {
-        ptr = dev;
         while (*ptr && !isdigit((int) *ptr))
         {
             ptr++;
-- 
2.35.1



_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

Reply via email to