There's a chance we can wrongly treat compressed file as a plain tar file. To prevent this, let's check for the compressed signatures first. --- src/buffer.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/src/buffer.c b/src/buffer.c index 4b44eaf..723ea71 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -390,14 +390,16 @@ check_compressed_archive (bool *pshort) /* Restore global values */ read_full_records = sfr; - if (tar_checksum (record_start, true) == HEADER_SUCCESS) - /* Probably a valid header */ - return ct_tar; - + /* Check for compressed signatures first, then check a tar checksum. + There's a chance of wrongly treat compressed file as a valid .tar file otherwise */ for (p = magic + 2; p < magic + NMAGIC; p++) if (memcmp (record_start->buffer, p->magic, p->length) == 0) return p->type; + if (tar_checksum (record_start, true) == HEADER_SUCCESS) + /* Probably a valid header */ + return ct_tar; + return ct_none; } -- 1.8.5.2