]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Issues 396, 397: Ignore entries with empty filenames.
authorTim Kientzle <kientzle@acm.org>
Sat, 7 Feb 2015 06:45:58 +0000 (22:45 -0800)
committerTim Kientzle <kientzle@acm.org>
Sat, 7 Feb 2015 06:45:58 +0000 (22:45 -0800)
Bugs in the rar and cab readers lead to returning entries
with empty filenames.  Make bsdtar resistant to this.

Of course, we should also fix the rar and cab
readers to handle these cases correctly and either
return correctly-populated entries or fail cleanly.

tar/read.c

index 8267b70e3a12c5378fd966169d087c7419ea9630..430cff0439a0f59f18da67bf29c57c2ed046dae4 100644 (file)
@@ -264,6 +264,12 @@ read_archive(struct bsdtar *bsdtar, char mode, struct archive *writer)
                }
                if (r == ARCHIVE_FATAL)
                        break;
+               const char *p = archive_entry_pathname(entry);
+               if (p == NULL || p[0] == '\0') {
+                       lafe_warnc(0, "Archive entry has empty or unreadable filename ... skipping.");
+                       bsdtar->return_value = 1;
+                       continue;
+               }
 
                if (bsdtar->uid >= 0) {
                        archive_entry_set_uid(entry, bsdtar->uid);