]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Check for errors in the return value of GetModuleFileNameW()
authorSelva Nair <selva.nair@gmail.com>
Sun, 14 May 2017 22:16:36 +0000 (18:16 -0400)
committerGert Doering <gert@greenie.muc.de>
Thu, 18 May 2017 09:26:50 +0000 (11:26 +0200)
Also replace MAX_PATH by _countof(openvpnpath) as the latter
is arguably more robust.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1494800196-8144-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14654.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/win32.c

index b27159730330a62ffad01995737f9a451acbb211..56c3a1d3f5bf02f46a53cbd44fdd8a609869cdf7 100644 (file)
@@ -1271,7 +1271,12 @@ win_wfp_block_dns (const NET_IFINDEX index)
     dmsg (D_LOW, "Tap Luid: %I64d", tapluid.Value);
 
     /* Get OpenVPN path. */
-    GetModuleFileNameW(NULL, openvpnpath, MAX_PATH);
+    status = GetModuleFileNameW(NULL, openvpnpath, _countof(openvpnpath));
+    if (status == 0 || status == _countof(openvpnpath))
+    {
+        msg(M_WARN|M_ERRNO, "block_dns: failed to get executable path");
+        goto err;
+    }
 
     if (FwpmGetAppIdFromFileName0(openvpnpath, &openvpnblob) != ERROR_SUCCESS)
         goto err;