1
0
Fork 0

Fix windows path handling not to slip into UNC lookup (#10073) (#10084)

* Fix windows path handling not to slip into UNC lookup (#10073)

* make sure that we don't get more than one leading directory separator in front of the path, so windows doesn't mistakenly look it up as a UNC.

* make sure we don't build paths that start with two \'s

* Fix condition
This commit is contained in:
Wilfried Goesgens 2019-10-02 22:19:54 +02:00 committed by KVS85
parent 2584d69a33
commit 33318e0177
3 changed files with 23 additions and 5 deletions

View File

@ -1,6 +1,8 @@
v3.5.1 (XXXX-XX-XX)
-------------------
* Fix config directory handling, so we don't trap into UNC path lookups on Windows.
* Ignore symlinks when copying JavaScript files at startup via the option
`--javascript.copy-installation`. This potentially fixes the following
error message at startup:

View File

@ -115,7 +115,10 @@ std::string buildFilename(char const* path, char const* name) {
std::string result(path);
if (!result.empty()) {
result = removeTrailingSeparator(result) + TRI_DIR_SEPARATOR_CHAR;
result = removeTrailingSeparator(result);
if (result.length() != 1 || result[0] != TRI_DIR_SEPARATOR_CHAR) {
result += TRI_DIR_SEPARATOR_CHAR;
}
}
if (!result.empty() && *name == TRI_DIR_SEPARATOR_CHAR) {
@ -134,7 +137,10 @@ std::string buildFilename(std::string const& path, std::string const& name) {
std::string result(path);
if (!result.empty()) {
result = removeTrailingSeparator(result) + TRI_DIR_SEPARATOR_CHAR;
result = removeTrailingSeparator(result);
if (result.length() != 1 || result[0] != TRI_DIR_SEPARATOR_CHAR) {
result += TRI_DIR_SEPARATOR_CHAR;
}
}
if (!result.empty() && !name.empty() && name[0] == TRI_DIR_SEPARATOR_CHAR) {

View File

@ -2426,7 +2426,11 @@ int TRI_GetTempName(char const* directory, std::string& result, bool createFile,
std::string TRI_LocateInstallDirectory(char const* argv0, char const* binaryPath) {
std::string thisPath = TRI_LocateBinaryPath(argv0);
return TRI_GetInstallRoot(thisPath, binaryPath) + TRI_DIR_SEPARATOR_CHAR;
std::string ret = TRI_GetInstallRoot(thisPath, binaryPath);
if (ret.length() != 1 || ret != TRI_DIR_SEPARATOR_STR) {
ret += TRI_DIR_SEPARATOR_CHAR;
}
return ret;
}
////////////////////////////////////////////////////////////////////////////////
@ -2445,8 +2449,14 @@ std::string TRI_LocateConfigDirectory(char const* binaryPath) {
}
std::string r = TRI_LocateInstallDirectory(nullptr, binaryPath);
r += _SYSCONFDIR_;
std::string scDir = _SYSCONFDIR_;
if (r.length() == 1 &&
r == TRI_DIR_SEPARATOR_STR &&
scDir[0] == TRI_DIR_SEPARATOR_CHAR) {
r = scDir;
} else {
r += _SYSCONFDIR_;
}
r += std::string(1, TRI_DIR_SEPARATOR_CHAR);
return r;