diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-02-19 17:00:58 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2015-02-19 17:00:58 +0200 |
commit | 1847ec67cec36a17354115374954fea211d1f0da (patch) | |
tree | 1a9766aae51d46aa0de8c58f4f851d55578ab5fa /src/buffer.c | |
parent | 9c2b57232e3bc2e5ba85387560bcdd851849a128 (diff) | |
download | tar-1847ec67cec36a17354115374954fea211d1f0da.tar.gz |
Improve compression format recognition
Some comressed archives can pass the checksum test, which makes tar
treat them as uncompressed archives.
* src/buffer.c (check_compressed_archive): Test the checksum only
if the block we read looks like a valid tar header (i.e. has
a magic string).
Diffstat (limited to 'src/buffer.c')
-rw-r--r-- | src/buffer.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/buffer.c b/src/buffer.c index a7d89712..1a96595d 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -391,7 +391,10 @@ check_compressed_archive (bool *pshort) /* Restore global values */ read_full_records = sfr; - if (tar_checksum (record_start, true) == HEADER_SUCCESS) + if ((strcmp (record_start->header.magic, TMAGIC) == 0 || + strcmp (record_start->buffer + offsetof (struct posix_header, magic), + OLDGNU_MAGIC) == 0) && + tar_checksum (record_start, true) == HEADER_SUCCESS) /* Probably a valid header */ return ct_tar; |