From: jet <34238471+jet2jet@users.noreply.github.com> Date: Wed, 14 Aug 2024 08:39:22 +0000 (+0900) Subject: windows reader: set tree::current for initial tree walking (#2212) X-Git-Tag: v3.7.5~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dbb3b4d54213f988fce77c7fa7eaf63249cdbb5;p=thirdparty%2Flibarchive.git windows reader: set tree::current for initial tree walking (#2212) Fixes #2211 --- diff --git a/libarchive/archive_read_disk_windows.c b/libarchive/archive_read_disk_windows.c index 6b551f4bb..285747ea9 100644 --- a/libarchive/archive_read_disk_windows.c +++ b/libarchive/archive_read_disk_windows.c @@ -1955,6 +1955,8 @@ tree_dir_next_windows(struct tree *t, const wchar_t *pattern) t->visit_type = r != 0 ? r : TREE_ERROR_DIR; return (t->visit_type); } + /* Top stack item needs a regular visit. */ + t->current = t->stack; t->findData = &t->_findData; pattern = NULL; } else if (!FindNextFileW(t->d, &t->_findData)) { diff --git a/tar/test/test_option_H_upper.c b/tar/test/test_option_H_upper.c index 097a9729d..3f999d38e 100644 --- a/tar/test/test_option_H_upper.c +++ b/tar/test/test_option_H_upper.c @@ -78,7 +78,7 @@ DEFINE_TEST(test_option_H_upper) /* Test 3: With -H, some symlinks on command line. */ assertMakeDir("test3", 0755); assertEqualInt(0, - systemf("%s -cf test3/archive.tar -H -C in ld1 d1 link2 linkY >test2/c.out 2>test2/c.err", testprog)); + systemf("%s -cf test3/archive.tar -H -C in ld1 d1 link2 linkY >test3/c.out 2>test3/c.err", testprog)); assertChdir("test3"); assertEqualInt(0, systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); @@ -88,4 +88,20 @@ DEFINE_TEST(test_option_H_upper) assertIsReg("link2", umasked(0644)); assertIsSymlink("linkY", "d1/fileY", 0); assertChdir(".."); + +#if defined(_WIN32) && !defined(__CYGWIN__) + /* Test 4: With -H, using wildcards with some symlinks on command line. (wildcards are supported only in Windows) */ + assertMakeDir("test4", 0755); + assertEqualInt(0, + systemf("%s -cf test4/archive.tar -H -C in * >test4/c.out 2>test4/c.err", testprog)); + assertChdir("test4"); + assertEqualInt(0, + systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); + assertIsDir("ld1", umasked(0755)); + assertIsSymlink("d1/linkX", "fileX", 0); + assertIsSymlink("d1/link1", "file1", 0); + assertIsReg("link2", umasked(0644)); + assertIsSymlink("linkY", "d1/fileY", 0); + assertChdir(".."); +#endif } diff --git a/tar/test/test_option_L_upper.c b/tar/test/test_option_L_upper.c index fd1ed0a52..60cffe49f 100644 --- a/tar/test/test_option_L_upper.c +++ b/tar/test/test_option_L_upper.c @@ -78,7 +78,7 @@ DEFINE_TEST(test_option_L_upper) /* Test 3: With -L, some symlinks on command line. */ assertMakeDir("test3", 0755); assertEqualInt(0, - systemf("%s -cf test3/archive.tar -L -C in ld1 d1 link2 linkY >test2/c.out 2>test2/c.err", testprog)); + systemf("%s -cf test3/archive.tar -L -C in ld1 d1 link2 linkY >test3/c.out 2>test3/c.err", testprog)); assertChdir("test3"); assertEqualInt(0, systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); @@ -88,4 +88,20 @@ DEFINE_TEST(test_option_L_upper) assertIsReg("link2", umasked(0644)); assertIsSymlink("linkY", "d1/fileY", 0); assertChdir(".."); + +#if defined(_WIN32) && !defined(__CYGWIN__) + /* Test 4: With -L, using wildcards with some symlinks on command line. (wildcards are supported only in Windows) */ + assertMakeDir("test4", 0755); + assertEqualInt(0, + systemf("%s -cf test4/archive.tar -L -C in * >test4/c.out 2>test4/c.err", testprog)); + assertChdir("test4"); + assertEqualInt(0, + systemf("%s -xf archive.tar >c.out 2>c.err", testprog)); + assertIsDir("ld1", umasked(0755)); + assertIsReg("d1/link1", umasked(0644)); + assertIsSymlink("d1/linkX", "fileX", 0); + assertIsReg("link2", umasked(0644)); + assertIsSymlink("linkY", "d1/fileY", 0); + assertChdir(".."); +#endif }