This commit is contained in:
DavidXanatos 2024-06-16 19:04:23 +02:00
parent b49c7fcde1
commit 6a5dec1647
2 changed files with 25 additions and 20 deletions

View File

@ -29,6 +29,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- fixed Chrome stopped printing [#3926](https://github.com/sandboxie-plus/Sandboxie/issues/3926)
- Sandboxie will add CustomChromiumFlags=--disable-features=PrintCompositorLPAC to chrome based browsers command line
- Note: Less Privileged App Container (LPAC) don't work with sandboxie currently
- fixed Problem accessing a relative symlink with a target that starts with a dot [#3981](https://github.com/sandboxie-plus/Sandboxie/issues/3981)

View File

@ -3172,44 +3172,48 @@ WCHAR* File_CanonizePath(const wchar_t* absolute_path, ULONG abs_path_len, const
ULONG i, j;
while(absolute_path[abs_path_len-1] == L'\\')
abs_path_len--;
abs_path_len--;
WCHAR* result = Dll_Alloc((abs_path_len + rel_path_len + 1) * sizeof(wchar_t));
WCHAR* result = (WCHAR*)Dll_Alloc((abs_path_len + rel_path_len + 1) * sizeof(wchar_t));
if (!result) return NULL;
wcsncpy(result, absolute_path, abs_path_len);
result[abs_path_len] = 0;
for (i = 0; i < rel_path_len; ) {
for (i = 0; i < rel_path_len; ) {
if (relative_path[i] == L'.' && relative_path[i + 1] == L'.' && (relative_path[i + 2] == L'\\' || relative_path[i + 2] == L'\0')) {
if (relative_path[i] == L'.' && relative_path[i + 1] == L'.' && (relative_path[i + 2] == L'\\' || relative_path[i + 2] == L'\0')) {
for (j = abs_path_len - 1; j >= 0 && result[j] != L'\\'; --j)
result[j] = L'\0';
if (j >= 0)
result[j] = L'\0';
for (j = abs_path_len - 1; j >= 0 && result[j] != L'\\'; --j)
result[j] = L'\0';
if (j >= 0)
result[j] = L'\0';
abs_path_len = j;
abs_path_len = j;
i += 3;
i += 3;
} else if (relative_path[i] == L'.') {
} else if (relative_path[i] == L'.' && (relative_path[i + 1] == L'\\' || relative_path[i + 1] == L'\0')) {
i += 2;
i += 2;
} else {
} else {
for (j = i; j < rel_path_len && relative_path[j] != L'\\' && relative_path[j] != L'\0'; ++j)
;
result[abs_path_len] = L'\\';
wcsncpy(result + abs_path_len + 1, &relative_path[i], j - i);
result[abs_path_len + j - i + 1] = L'\0';
if (abs_path_len > 0 && result[abs_path_len - 1] != L'\\') {
result[abs_path_len] = L'\\';
abs_path_len++;
}
wcsncpy(result + abs_path_len, &relative_path[i], j - i);
result[abs_path_len + j - i] = L'\0';
abs_path_len += j - i + 1;
abs_path_len += j - i;
i = j + 1;
}
}
i = j + (relative_path[j] == L'\\' ? 1 : 0);
}
}
return result;
}