Blame SOURCES/tar-1.26-non-deterministic-archive-detection.patch

f4af7d
f4af7d
From 1847ec67cec36a17354115374954fea211d1f0da Mon Sep 17 00:00:00 2001
f4af7d
From: Sergey Poznyakoff <gray@gnu.org.ua>
f4af7d
Date: Thu, 19 Feb 2015 17:00:58 +0200
f4af7d
Subject: [PATCH] Improve compression format recognition
f4af7d
f4af7d
Some comressed archives can pass the checksum test, which makes tar
f4af7d
treat them as uncompressed archives.
f4af7d
f4af7d
* src/buffer.c (check_compressed_archive): Test the checksum only
f4af7d
if the block we read looks like a valid tar header (i.e. has
f4af7d
a magic string).
f4af7d
---
f4af7d
 src/buffer.c | 5 ++++-
f4af7d
 1 file changed, 4 insertions(+), 1 deletion(-)
f4af7d
f4af7d
diff --git a/src/buffer.c b/src/buffer.c
f4af7d
index a7d8971..1a96595 100644
f4af7d
--- a/src/buffer.c
f4af7d
+++ b/src/buffer.c
f4af7d
@@ -391,7 +391,10 @@ check_compressed_archive (bool *pshort)
f4af7d
   /* Restore global values */
f4af7d
   read_full_records = sfr;
f4af7d
 
f4af7d
-  if (tar_checksum (record_start, true) == HEADER_SUCCESS)
f4af7d
+  if ((strcmp (record_start->header.magic, TMAGIC) == 0 ||
f4af7d
+       strcmp (record_start->buffer + offsetof (struct posix_header, magic),
f4af7d
+	       OLDGNU_MAGIC) == 0) &&
f4af7d
+      tar_checksum (record_start, true) == HEADER_SUCCESS)
f4af7d
     /* Probably a valid header */
f4af7d
     return ct_tar;
f4af7d
 
f4af7d
-- 
f4af7d
2.13.5
f4af7d
f4af7d
f4af7d
f4af7d
From 1e8b786e651d174a5fc9bf63a08d00c2d592ee3e Mon Sep 17 00:00:00 2001
f4af7d
From: Pavel Raiskup <praiskup@redhat.com>
f4af7d
Date: Thu, 30 Mar 2017 13:30:15 +0200
f4af7d
Subject: [PATCH] Fix non-deterministic archive type detection
f4af7d
f4af7d
Due to analysis of partly uninitialized read-ahead buffer
f4af7d
(short_read call), we sometimes mistakenly classified very small
f4af7d
compressed archives as non-compressed; which in turn caused
f4af7d
extraction failure.
f4af7d
f4af7d
* src/buffer.c (check_compressed_archive): Don't assume that
f4af7d
archives smaller than BLOCKSIZE could be non-compressed, as tar
f4af7d
header always has at least one block.
f4af7d
---
f4af7d
 src/buffer.c | 10 ++++++----
f4af7d
 1 file changed, 6 insertions(+), 4 deletions(-)
f4af7d
f4af7d
diff --git a/src/buffer.c b/src/buffer.c
f4af7d
index 57fe813..6f96c2f 100644
f4af7d
--- a/src/buffer.c
f4af7d
+++ b/src/buffer.c
f4af7d
@@ -402,10 +402,12 @@ check_compressed_archive (bool *pshort)
f4af7d
   /* Restore global values */
f4af7d
   read_full_records = sfr;
f4af7d
 
f4af7d
-  if ((strcmp (record_start->header.magic, TMAGIC) == 0 ||
f4af7d
-       strcmp (record_start->buffer + offsetof (struct posix_header, magic),
f4af7d
-	       OLDGNU_MAGIC) == 0) &&
f4af7d
-      tar_checksum (record_start, true) == HEADER_SUCCESS)
f4af7d
+  if (record_start != record_end /* no files smaller than BLOCKSIZE */
f4af7d
+      && (strcmp (record_start->header.magic, TMAGIC) == 0
f4af7d
+          || strcmp (record_start->buffer + offsetof (struct posix_header,
f4af7d
+                                                      magic),
f4af7d
+                     OLDGNU_MAGIC) == 0)
f4af7d
+      && tar_checksum (record_start, true) == HEADER_SUCCESS)
f4af7d
     /* Probably a valid header */
f4af7d
     return ct_tar;
f4af7d
 
f4af7d
-- 
f4af7d
2.13.5
f4af7d