aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-04-22 14:22:44 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-04-22 14:22:44 +0200
commitc6b65ee8a9a57d51956ee462fa1d61fd90d61f40 (patch)
tree84465ce5c60eae3ee2a53a40fe3c4ced0c690778
parent9a20cc2f627c3fa086b109dd1830bf45519fcb55 (diff)
Skip PAX global headers
Tar archives can contain set two kinds of PAX headers: - local headers that modify the attributes of the next file - global headers that set defaults for all files The later is used "... not widely used", according to tar(5) and has been deliberately not implemented. Some programs (e.g. git-archive) *do* generate them (in the case of git, it stores the commit hash). This commit adds a code path that skips a PAX global header entirely and resumes tar parsing, instead of erroneusly reporting it as an entry. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/tar.h1
-rw-r--r--lib/tar/read_header.c5
2 files changed, 6 insertions, 0 deletions
diff --git a/include/tar.h b/include/tar.h
index def36be..af3c9ab 100644
--- a/include/tar.h
+++ b/include/tar.h
@@ -105,6 +105,7 @@ typedef struct {
#define TAR_TYPE_GNU_SPARSE 'S'
#define TAR_TYPE_PAX 'x'
+#define TAR_TYPE_PAX_GLOBAL 'g'
#define TAR_MAGIC "ustar"
#define TAR_VERSION "00"
diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c
index 2918d09..1f20334 100644
--- a/lib/tar/read_header.c
+++ b/lib/tar/read_header.c
@@ -222,6 +222,11 @@ int read_header(FILE *fp, tar_header_decoded_t *out)
goto fail;
set_by_pax |= PAX_NAME;
continue;
+ case TAR_TYPE_PAX_GLOBAL:
+ if (read_number(hdr.size, sizeof(hdr.size), &pax_size))
+ goto fail;
+ skip_entry(fp, pax_size);
+ continue;
case TAR_TYPE_PAX:
clear_header(out);
if (read_number(hdr.size, sizeof(hdr.size), &pax_size))