Check for errors in the return value of GetModuleFileNameW()
PATCH 1/1 Check for errors in the return value of GetModuleFileNameW()
From: Selva Nair <[email protected]...>
Also replace MAX_PATH by _countof(openvpnpath) as the latter is arguably more robust.
Signed-off-by Selva Nair <[email protected]...>
--- src/openvpn/win32.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
src/openvpn/win32.c +6 -1
@@ -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;
Signature · 1 line
2.1.4
ACK, thanks. This brings 2.3 in line with 2.4/master, which is good :-)
Your patch has been applied to the release/2.3 branch.
commit c18802e2e2c5b156d1b40dab255cea273131a96c
Author: Selva Nair Date: Sun May 14 18:16:36 2017 -0400
Check for errors in the return value of GetModuleFileNameW()
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg14654.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering