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

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