msvcrt: Add support for quoted paths in _wsearchenv_s.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
feature/deterministic
Piotr Caban 2020-01-29 13:42:19 +01:00 committed by Alexandre Julliard
parent 98c554ac06
commit f05549b7f7
1 changed files with 18 additions and 3 deletions

View File

@ -1833,12 +1833,27 @@ int CDECL MSVCRT__wsearchenv_s(const MSVCRT_wchar_t* file, const MSVCRT_wchar_t*
for(; *penv; penv = (*end ? end + 1 : end))
{
end = penv;
while(*end && *end != ';') end++; /* Find end of next path */
path_len = end - penv;
path_len = 0;
while(*end && *end != ';' && path_len < MAX_PATH)
{
if (*end == '"')
{
end++;
while(*end && *end != '"' && path_len < MAX_PATH)
{
path[path_len++] = *end;
end++;
}
if (*end == '"') end++;
continue;
}
path[path_len++] = *end;
end++;
}
if (!path_len || path_len >= MAX_PATH)
continue;
memcpy(path, penv, path_len * sizeof(MSVCRT_wchar_t));
if (path[path_len - 1] != '/' && path[path_len - 1] != '\\')
path[path_len++] = '\\';
if (path_len + fname_len >= MAX_PATH)