]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
windows reader: set tree::current for initial tree walking (#2212)
authorjet <34238471+jet2jet@users.noreply.github.com>
Wed, 14 Aug 2024 08:39:22 +0000 (17:39 +0900)
committerGitHub <noreply@github.com>
Wed, 14 Aug 2024 08:39:22 +0000 (10:39 +0200)
Fixes #2211

libarchive/archive_read_disk_windows.c
tar/test/test_option_H_upper.c
tar/test/test_option_L_upper.c

index 6b551f4bb0a7e7b0b2e0c2860867ac9fa81ab652..285747ea91e0694ebcc3ea714569d268e6466ee7 100644 (file)
@@ -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)) {
index 097a9729d26ff0a2919bda3dbcea999e2fa36ae4..3f999d38e809d3cf1d76e8b45d7d6a9873cc5262 100644 (file)
@@ -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
 }
index fd1ed0a52c765ead2cba4db0edc2781d55b87459..60cffe49f9d4254e56a88c5ce32cfe68cf89f492 100644 (file)
@@ -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
 }