bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] 'BZh[1-9]' file in v7 format archive confuses GNU tar


From: Sergey Poznyakoff
Subject: Re: [Bug-tar] 'BZh[1-9]' file in v7 format archive confuses GNU tar
Date: Tue, 27 Nov 2018 13:47:20 +0200

Michał Górny <address@hidden> ha escrit:

> $ echo test > BZh5
> $ tar --format=v7 -cf test.tar BZh5
> $ tar -xf test.tar
> bzip2: stdin: compressed data error: bad block header magic
> tar: Child returned status 1
> tar: Error is not recoverable: exiting now

Before attempting compression format identification, tar tests if
the first block read is a valid tar header block. However, the
test itself is stricter than necessary. The following patch should
fix this:

diff --git a/src/buffer.c b/src/buffer.c
index ddb63cc..5632aee 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -406,10 +406,6 @@ check_compressed_archive (bool *pshort)
   read_full_records = sfr;
 
   if (record_start != record_end /* no files smaller than BLOCKSIZE */
-      && (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;

Regards,
Sergey



reply via email to

[Prev in Thread] Current Thread [Next in Thread]