From: Hans Leidekker hans@codeweavers.com
--- programs/xcopy/tests/xcopy.c | 7 +++++++ programs/xcopy/xcopy.c | 13 ++++++------- 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/programs/xcopy/tests/xcopy.c b/programs/xcopy/tests/xcopy.c index 61fbad9ccaf..e038f69ad02 100644 --- a/programs/xcopy/tests/xcopy.c +++ b/programs/xcopy/tests/xcopy.c @@ -117,6 +117,13 @@ static void test_parms_syntax(void) ok(GetFileAttributesA("xcopytest2") != INVALID_FILE_ATTRIBUTES, "xcopy failed to copy empty directory\n"); RemoveDirectoryA("xcopytest2"); + + CreateDirectoryA("xcopy test2", NULL); + rc = runcmd("xcopy /S/R/Y/I "xcopytest" "xcopy test2""); + ok(rc == 0, "xcopy /S/R/Y/I test failed rc=%lu\n", rc); + ok(GetFileAttributesA("xcopy test2") != INVALID_FILE_ATTRIBUTES, + "xcopy failed to copy empty directory\n"); + RemoveDirectoryA("xcopy test2"); }
static void test_keep_attributes(void) diff --git a/programs/xcopy/xcopy.c b/programs/xcopy/xcopy.c index 46a2727dd49..ce3e40d7d5e 100644 --- a/programs/xcopy/xcopy.c +++ b/programs/xcopy/xcopy.c @@ -665,17 +665,16 @@ static inline BOOL is_digit(WCHAR c) static int get_arg(const WCHAR **cmdline, WCHAR **arg) { const WCHAR *ptr = *cmdline; - int len; + int len, in_quotes = 0;
if (*ptr == '/') ptr++; - while (*ptr && !is_whitespace(*ptr) && *ptr != '/') { - if (*ptr == '"') { - while (*ptr && *ptr != '"') ptr++; - /* Odd number of double quotes is illegal for XCOPY */ - if (!*ptr) return RC_INITERROR; - } + while (*ptr) { + if (*ptr == '"') in_quotes = !in_quotes; + if ((*ptr == '/' || is_whitespace(*ptr)) && !in_quotes) break; ptr++; } + /* Odd number of double quotes is illegal for XCOPY */ + if (in_quotes) return RC_INITERROR;
len = ptr - *cmdline; *arg = malloc((len + 1) * sizeof(WCHAR));