Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2039?usp=email
to review the following change.
Change subject: plugin: detect too long plugin paths on Windows
......................................................................
plugin: detect too long plugin paths on Windows
GetFullPathNameW() returns the required buffer size if the normalized
path doesn't fit. This case is currently not checked, so a normalized
path longer than MAX_PATH left the buffer empty and the plugin was
then rejected with the misleading message that it is not located in
a trusted directory.
Treat a return value that does not fit into the buffer as failure, so
that the error says that the path could not be normalized. Since
GetFullPathNameW() sets no error code, set ERROR_FILENAME_EXCED_RANGE
manually before logging.
Change-Id: Ib40b439ad84a08fe6d5d4407da18ed78151327e7
Signed-off-by: Heiko Hund <[email protected]>
---
M src/openvpn/plugin.c
1 file changed, 7 insertions(+), 1 deletion(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/39/2039/1
diff --git a/src/openvpn/plugin.c b/src/openvpn/plugin.c
index a94f07b..9826510 100644
--- a/src/openvpn/plugin.c
+++ b/src/openvpn/plugin.c
@@ -284,8 +284,14 @@
WCHAR *wpath = wide_string(p->so_pathname, &gc);
WCHAR normalized_plugin_path[MAX_PATH] = { 0 };
/* Normalize the plugin path, converting any relative paths to absolute
paths. */
- if (!GetFullPathNameW(wpath, MAX_PATH, normalized_plugin_path, NULL))
+ DWORD len = GetFullPathNameW(wpath, _countof(normalized_plugin_path),
normalized_plugin_path, NULL);
+ if (len == 0 || len >= _countof(normalized_plugin_path))
{
+ /* GetFullPathNameW() sets no error code if the buffer is too small */
+ if (len != 0)
+ {
+ SetLastError(ERROR_FILENAME_EXCED_RANGE);
+ }
msg(M_ERR, "PLUGIN_INIT: could not load plugin DLL: %ls. Failed to
normalize plugin path.",
wpath);
}
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2039?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ib40b439ad84a08fe6d5d4407da18ed78151327e7
Gerrit-Change-Number: 2039
Gerrit-PatchSet: 1
Gerrit-Owner: Heiko Hund <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel