Merge pull request #2968 from stoeckmann/isofile_gen_utility_names_dotdot
iso9660: Fix `..` (dot dot) path normalization
(cherry picked from commit 45d9c12632)
This commit is contained in:
1 parent
7242dfa1d8
commit
6e6865af32
2 files changed
+13
-4
No files matched your search
@@ -4910,20 +4910,29 @@ isofile_gen_utility_names(struct archive_write *a, struct isofile *file)
|
||||
* --> 'dir/dir2/'
|
||||
*/
|
||||
char *rp = p -1;
|
||||
size_t off;
|
||||
for (off = 4; p[off] == '/'; off++)
|
||||
;
|
||||
while (rp >= dirname) {
|
||||
if (*rp == '/')
|
||||
break;
|
||||
--rp;
|
||||
}
|
||||
if (rp > dirname) {
|
||||
strcpy(rp, p+3);
|
||||
memmove(rp + 1, p + off, strlen(p + off) + 1);
|
||||
p = rp;
|
||||
} else {
|
||||
strcpy(dirname, p+4);
|
||||
memmove(dirname, p + off, strlen(p + off) + 1);
|
||||
p = dirname;
|
||||
}
|
||||
} else
|
||||
p++;
|
||||
} else if (p == dirname && p[0] == '.' && p[1] == '.' && p[2] == '/') {
|
||||
size_t off;
|
||||
for (off = 3; p[off] == '/'; off++)
|
||||
;
|
||||
memmove(dirname, p + off, strlen(p + off) + 1);
|
||||
p = dirname;
|
||||
} else
|
||||
p++;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ DEFINE_TEST(test_write_format_iso9660)
|
||||
archive_entry_set_birthtime(ae, 3, 30);
|
||||
archive_entry_set_ctime(ae, 4, 40);
|
||||
archive_entry_set_mtime(ae, 5, 50);
|
||||
archive_entry_copy_pathname(ae, "dir0/dir1/file1");
|
||||
archive_entry_copy_pathname(ae, "dir0/../../dir0/dir1/file1");
|
||||
archive_entry_set_mode(ae, AE_IFREG | 0755);
|
||||
archive_entry_set_size(ae, 8);
|
||||
archive_entry_set_nlink(ae, 1);
|
||||
@@ -170,7 +170,7 @@ DEFINE_TEST(test_write_format_iso9660)
|
||||
archive_entry_set_birthtime(ae, 3, 30);
|
||||
archive_entry_set_ctime(ae, 4, 40);
|
||||
archive_entry_set_mtime(ae, 5, 50);
|
||||
archive_entry_copy_pathname(ae, "dir0/dir1/file2");
|
||||
archive_entry_copy_pathname(ae, "dir0/..//dir0/dir1/file2");
|
||||
archive_entry_set_mode(ae, AE_IFREG | 0755);
|
||||
archive_entry_set_size(ae, 8);
|
||||
archive_entry_set_nlink(ae, 1);
|
||||
|
||||
Reference in new issue
Block a user