[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: |
Michał Górny |
Subject: |
Re: [Bug-tar] 'BZh[1-9]' file in v7 format archive confuses GNU tar |
Date: |
Wed, 28 Nov 2018 14:57:41 +0100 |
On Wed, 2018-11-28 at 14:32 +0200, Sergey Poznyakoff wrote:
> Michał Górny <address@hidden> ha escrit:
>
> > FWICS the problem is that one of the checksum variants evaluates to zero
> > and tar is rather lax on accepting null checksum string (with trailing
> > garbage) as zero.
>
> That's easy to fix (see the attached patch). I'm not quite convinced
> that it doesn't break backward compatibility though (can such headers be
> found in some old archives?)
Well, I was thinking of applying the change only to the heuristic used
to detect compression, i.e. still being lax on accepting tarballs that
don't look like they're compressed.
> 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;
> diff --git a/src/list.c b/src/list.c
> index ba9c306..0dacbb7 100644
> --- a/src/list.c
> +++ b/src/list.c
> @@ -892,6 +892,11 @@ from_header (char const *where0, size_t digs, char const
> *type,
> value = -value;
> }
>
> + /* Skip consecutive \0's. This ensures the test below will catch eventual
> + trailing garbage */
> + while (where < lim && !*where)
> + where++;
Does this fail if checksum consists solely of NULs without a single
octal digit?
> +
> if (where != lim && *where && !isspace ((unsigned char) *where))
> {
> if (type)
--
Best regards,
Michał Górny
signature.asc
Description: This is a digitally signed message part