Module: wine Branch: stable Commit: bfd41ed7a9bb5f4ac9b125260aa727ab1fbb629f URL: https://source.winehq.org/git/wine.git/?a=commit;h=bfd41ed7a9bb5f4ac9b125260...
Author: Piotr Caban piotr@codeweavers.com Date: Tue Jan 28 18:26:12 2020 +0100
msvcrt: Add support for quoted paths in _searchenv.
Signed-off-by: Piotr Caban piotr@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org (cherry picked from commit 1d0cca465ab6b185dd91db00f61d9ad5d272a766) Signed-off-by: Michael Stefaniuc mstefani@winehq.org
---
dlls/msvcrt/dir.c | 21 ++++++++++++++++++--- dlls/msvcrt/tests/dir.c | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcrt/dir.c b/dlls/msvcrt/dir.c index e8cba58ac7..d07fcd6c7d 100644 --- a/dlls/msvcrt/dir.c +++ b/dlls/msvcrt/dir.c @@ -1683,12 +1683,27 @@ void CDECL MSVCRT__searchenv(const char* file, const char* env, char *buf) 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); if (path[path_len - 1] != '/' && path[path_len - 1] != '\') path[path_len++] = '\'; if (path_len + fname_len >= MAX_PATH) diff --git a/dlls/msvcrt/tests/dir.c b/dlls/msvcrt/tests/dir.c index 210cf3983c..6c817dfb2e 100644 --- a/dlls/msvcrt/tests/dir.c +++ b/dlls/msvcrt/tests/dir.c @@ -597,6 +597,20 @@ static void test_searchenv(void) ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); }
+ strcpy(env1, "TEST_PATH="); + strcat(env1, tmppath); + strcat(env1, ""\search_env_test\"d"i"r"1"); + putenv(env1); + strcpy(exp, tmppath); + strcat(exp, files[0]); + _searchenv("1.dat", "TEST_PATH", result); + ok(!strcmp(result, exp), "got %s, expected '%s'\n", result, exp); + + strcat(env1, ";"); + putenv(env1); + _searchenv("1.dat", "TEST_PATH", result); + ok(!result[0], "got %s, expected ''\n", result); + putenv("TEST_PATH=");
for (i=ARRAY_SIZE(files)-1; i>=0; i--) {