From 7feabaaeb5c3aa6f761e181d6c16b1aeabcfd46f Mon Sep 17 00:00:00 2001 From: Savely Krasovsky Date: Thu, 22 Feb 2024 16:19:17 +0100 Subject: [PATCH] Update agentconfig.hpp --- openvpn/client/win/agentconfig.hpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/openvpn/client/win/agentconfig.hpp b/openvpn/client/win/agentconfig.hpp index 4876ef2cf..a30080657 100644 --- a/openvpn/client/win/agentconfig.hpp +++ b/openvpn/client/win/agentconfig.hpp @@ -53,18 +53,12 @@ class Agent } private: - // If path starts with C:\..., lower-case the drive letter. + // Convert to lower-case (in some cases GetModuleFileNameW returns lower case path). // Then strip off the basename and only return the dir. static std::string normalize_exe_path(const std::string &path) { std::string p; - if (path.length() >= 3 - && std::isalpha(static_cast(path[0])) != 0 - && path[1] == ':' - && path[2] == '\\') - p = string::to_lower_copy(path.substr(0, 3)) + path.substr(3); - else - p = path; + std::transform(p.begin(), p.end(), p.begin(), std::towlower); p = path::dirname(p); return p; }