From: Selva Nair Date: Sun, 14 May 2017 22:16:36 +0000 (-0400) Subject: Check for errors in the return value of GetModuleFileNameW() X-Git-Tag: v2.3.16~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c18802e2e2c5b156d1b40dab255cea273131a96c;p=thirdparty%2Fopenvpn.git Check for errors in the return value of GetModuleFileNameW() Also replace MAX_PATH by _countof(openvpnpath) as the latter is arguably more robust. Signed-off-by: Selva Nair Acked-by: Gert Doering 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 --- diff --git a/src/openvpn/win32.c b/src/openvpn/win32.c index b27159730..56c3a1d3f 100644 --- a/src/openvpn/win32.c +++ b/src/openvpn/win32.c @@ -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;