summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDavid Lönnhager <david.l@mullvad.net>2019-11-04 14:57:15 +0100
committerDavid Lönnhager <david.l@mullvad.net>2019-11-04 14:57:15 +0100
commitea6ca75a2c360048b807ce6108866a655371c2f3 (patch)
treeb85662b0fe639c0b762d399a9d8b97e73dd75ea5
parentd3466776256d37c46de3ed4457b165f3dbcb9783 (diff)
parent35724086177f07a27f6d4f4f80dac4d25a65d270 (diff)
downloadmullvadvpn-ea6ca75a2c360048b807ce6108866a655371c2f3.tar.xz
mullvadvpn-ea6ca75a2c360048b807ce6108866a655371c2f3.zip
Merge branch 'path-type-workaround'
-rw-r--r--CHANGELOG.md3
-rw-r--r--windows/nsis-plugins/src/pathedit/pathedit.cpp19
2 files changed, 20 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ab87cd50d..760e303df3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -42,6 +42,9 @@ Line wrap the file at 100 chars. Th
### Fixed
#### Windows
- Detect removal of the OpenVPN TAP adapter on reconnection attempts.
+- Improve robustness in path environment variable logic in Windows installer. Handle the case
+ where the registry value type is incorrectly set to be a regular string rather than an expandable
+ string.
## [2019.9] - 2019-10-11
diff --git a/windows/nsis-plugins/src/pathedit/pathedit.cpp b/windows/nsis-plugins/src/pathedit/pathedit.cpp
index fda83d779e..09f0ddbfec 100644
--- a/windows/nsis-plugins/src/pathedit/pathedit.cpp
+++ b/windows/nsis-plugins/src/pathedit/pathedit.cpp
@@ -68,6 +68,21 @@ bool SysPathExists(const std::wstring &allPaths, const std::wstring &pathToFind)
auto pathTokens = common::string::Tokenize(allPaths, L";");
return FindSysPath(pathTokens, pathToFind) != pathTokens.end();
}
+
+std::wstring ReadPathValue(const RegistryKey &pathKey)
+{
+ // Some applications will replace the PATH value with a regular string;
+ // use this type as a fallback.
+ try
+ {
+ return pathKey.readString(pathValName, ValueStringType::ExpandableString);
+ }
+ catch (const std::exception &)
+ {
+ return pathKey.readString(pathValName, ValueStringType::RegularString);
+ }
+}
+
} // anonymous namespace
//
@@ -109,7 +124,7 @@ void __declspec(dllexport) NSISCALL AddSysEnvPath
true,
RegistryView::Force64
);
- auto path = pathRegKey->readString(pathValName, ValueStringType::ExpandableString);
+ std::wstring path = ReadPathValue(*pathRegKey);
if (SysPathExists(path, pathToAppend))
{
@@ -180,7 +195,7 @@ void __declspec(dllexport) NSISCALL RemoveSysEnvPath
true,
RegistryView::Force64
);
- auto path = pathRegKey->readString(pathValName, ValueStringType::ExpandableString);
+ std::wstring path = ReadPathValue(*pathRegKey);
// remove value if it exists in PATH
auto pathTokens = common::string::Tokenize(path, L";");