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

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