msvcrt: Add support for quoted paths in _searchenv_s.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2020-01-29 13:42:11 +01:00 committed by Alexandre Julliard
parent 3a67291af4
commit 2e7ad72a8d
1 changed files with 18 additions and 3 deletions

View File

@ -1763,12 +1763,27 @@ int CDECL MSVCRT__searchenv_s(const char* file, const char* env, char *buf, MSVC
for(; *penv; penv = (*end ? end + 1 : end)) for(; *penv; penv = (*end ? end + 1 : end))
{ {
end = penv; end = penv;
while(*end && *end != ';') end++; /* Find end of next path */ path_len = 0;
path_len = end - penv; 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) if (!path_len || path_len >= MAX_PATH)
continue; continue;
memcpy(path, penv, path_len);
if (path[path_len - 1] != '/' && path[path_len - 1] != '\\') if (path[path_len - 1] != '/' && path[path_len - 1] != '\\')
path[path_len++] = '\\'; path[path_len++] = '\\';
if (path_len + fname_len >= MAX_PATH) if (path_len + fname_len >= MAX_PATH)