summaryrefslogtreecommitdiff
path: root/tar/tar2sqfs.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-23 13:51:01 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-10-23 13:56:33 +0200
commit063f57dec14986d1895d83d9113fd1dec7f135f4 (patch)
tree064348a4e68455a0e9f75014fca940f3ed348541 /tar/tar2sqfs.c
parent018e0e0a8e3c36a6bedf60eedeb8262311d90869 (diff)
Fix tar2sqfs: check for empty names or './' entrty
This commit makes sure entries with empty file names are skipped by tar2sqfs. The case of a directory with the name './' is treated specially, because tar can generate in some common use cases. For instance: $ mkdir foo $ touch foo/bar $ tar -C ./foo -c . > out.tar $ tar tf out.tar will generate a tar file with an entry named './'. For the future it might be interesting to turn that into the root inode somehow. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar/tar2sqfs.c')
-rw-r--r--tar/tar2sqfs.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c
index 627cae9..30f1abb 100644
--- a/tar/tar2sqfs.c
+++ b/tar/tar2sqfs.c
@@ -345,12 +345,26 @@ static int process_tar_ball(void)
skip = false;
+ if (hdr.name != NULL && strcmp(hdr.name, "./") == 0 &&
+ S_ISDIR(hdr.sb.st_mode)) {
+ /* XXX: tar entries might be prefixed with ./ which is
+ stripped by cannonicalize_name, but the tar file may
+ contain a directory entry named './' */
+ clear_header(&hdr);
+ continue;
+ }
+
if (hdr.name == NULL || canonicalize_name(hdr.name) != 0) {
fprintf(stderr, "skipping '%s' (invalid name)\n",
hdr.name);
skip = true;
}
+ if (hdr.name[0] == '\0') {
+ fputs("skipping entry with empty name\n", stderr);
+ skip = true;
+ }
+
if (!skip && hdr.unknown_record) {
fprintf(stderr, "%s: unknown entry type\n", hdr.name);
skip = true;