Skip to content

Commit 8dbb3b4

Browse files
authored
windows reader: set tree::current for initial tree walking (libarchive#2212)
Fixes libarchive#2211
1 parent c39372f commit 8dbb3b4

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

libarchive/archive_read_disk_windows.c

+2
Original file line numberDiff line numberDiff line change
@@ -1955,6 +1955,8 @@ tree_dir_next_windows(struct tree *t, const wchar_t *pattern)
19551955
t->visit_type = r != 0 ? r : TREE_ERROR_DIR;
19561956
return (t->visit_type);
19571957
}
1958+
/* Top stack item needs a regular visit. */
1959+
t->current = t->stack;
19581960
t->findData = &t->_findData;
19591961
pattern = NULL;
19601962
} else if (!FindNextFileW(t->d, &t->_findData)) {

tar/test/test_option_H_upper.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ DEFINE_TEST(test_option_H_upper)
7878
/* Test 3: With -H, some symlinks on command line. */
7979
assertMakeDir("test3", 0755);
8080
assertEqualInt(0,
81-
systemf("%s -cf test3/archive.tar -H -C in ld1 d1 link2 linkY >test2/c.out 2>test2/c.err", testprog));
81+
systemf("%s -cf test3/archive.tar -H -C in ld1 d1 link2 linkY >test3/c.out 2>test3/c.err", testprog));
8282
assertChdir("test3");
8383
assertEqualInt(0,
8484
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
@@ -88,4 +88,20 @@ DEFINE_TEST(test_option_H_upper)
8888
assertIsReg("link2", umasked(0644));
8989
assertIsSymlink("linkY", "d1/fileY", 0);
9090
assertChdir("..");
91+
92+
#if defined(_WIN32) && !defined(__CYGWIN__)
93+
/* Test 4: With -H, using wildcards with some symlinks on command line. (wildcards are supported only in Windows) */
94+
assertMakeDir("test4", 0755);
95+
assertEqualInt(0,
96+
systemf("%s -cf test4/archive.tar -H -C in * >test4/c.out 2>test4/c.err", testprog));
97+
assertChdir("test4");
98+
assertEqualInt(0,
99+
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
100+
assertIsDir("ld1", umasked(0755));
101+
assertIsSymlink("d1/linkX", "fileX", 0);
102+
assertIsSymlink("d1/link1", "file1", 0);
103+
assertIsReg("link2", umasked(0644));
104+
assertIsSymlink("linkY", "d1/fileY", 0);
105+
assertChdir("..");
106+
#endif
91107
}

tar/test/test_option_L_upper.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ DEFINE_TEST(test_option_L_upper)
7878
/* Test 3: With -L, some symlinks on command line. */
7979
assertMakeDir("test3", 0755);
8080
assertEqualInt(0,
81-
systemf("%s -cf test3/archive.tar -L -C in ld1 d1 link2 linkY >test2/c.out 2>test2/c.err", testprog));
81+
systemf("%s -cf test3/archive.tar -L -C in ld1 d1 link2 linkY >test3/c.out 2>test3/c.err", testprog));
8282
assertChdir("test3");
8383
assertEqualInt(0,
8484
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
@@ -88,4 +88,20 @@ DEFINE_TEST(test_option_L_upper)
8888
assertIsReg("link2", umasked(0644));
8989
assertIsSymlink("linkY", "d1/fileY", 0);
9090
assertChdir("..");
91+
92+
#if defined(_WIN32) && !defined(__CYGWIN__)
93+
/* Test 4: With -L, using wildcards with some symlinks on command line. (wildcards are supported only in Windows) */
94+
assertMakeDir("test4", 0755);
95+
assertEqualInt(0,
96+
systemf("%s -cf test4/archive.tar -L -C in * >test4/c.out 2>test4/c.err", testprog));
97+
assertChdir("test4");
98+
assertEqualInt(0,
99+
systemf("%s -xf archive.tar >c.out 2>c.err", testprog));
100+
assertIsDir("ld1", umasked(0755));
101+
assertIsReg("d1/link1", umasked(0644));
102+
assertIsSymlink("d1/linkX", "fileX", 0);
103+
assertIsReg("link2", umasked(0644));
104+
assertIsSymlink("linkY", "d1/fileY", 0);
105+
assertChdir("..");
106+
#endif
91107
}

0 commit comments

Comments
 (0)