]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
mtree: Root entry '.' must be directory 3057/head
authori1011 <petercheng2000@gmail.com>
Wed, 20 May 2026 16:44:39 +0000 (00:44 +0800)
committeri1011 <petercheng2000@gmail.com>
Sun, 24 May 2026 11:41:16 +0000 (19:41 +0800)
libarchive/archive_write_set_format_mtree.c

index 656a196f410c979e16106b0e0970d5761e3c1b8d..ed53849bfbbcb99a31946990fc514c8fbb74d5b9 100644 (file)
@@ -2088,6 +2088,11 @@ mtree_entry_tree_add(struct archive_write *a, struct mtree_entry **filep)
        file = *filep;
        if (file->parentdir.length == 0 && file->basename.length == 1 &&
            file->basename.s[0] == '.') {
+               if (file->filetype != AE_IFDIR) {
+                       archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+                               "Root entry '.' must be a directory");
+                       return (ARCHIVE_FAILED);
+               }
                file->parent = file;
                if (mtree->root != NULL) {
                        np = mtree->root;