]> Dogcows Code - chaz/tar/commitdiff
Improve compression format recognition
authorSergey Poznyakoff <gray@gnu.org.ua>
Thu, 19 Feb 2015 15:00:58 +0000 (17:00 +0200)
committerSergey Poznyakoff <gray@gnu.org.ua>
Thu, 19 Feb 2015 15:00:58 +0000 (17:00 +0200)
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).

src/buffer.c

index a7d89712fc0d931dddd948403f95249a1c7f0c6e..1a96595d9a982168d1da56f53863fdd6ee069f11 100644 (file)
@@ -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;
 
This page took 0.022774 seconds and 4 git commands to generate.