]> git.ipfire.org Git - thirdparty/git.git/commit - t/t5000-tar-tree.sh
t5000: test tar files that overflow ustar headers
authorJeff King <peff@peff.net>
Thu, 30 Jun 2016 09:08:57 +0000 (05:08 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Jul 2016 17:24:18 +0000 (10:24 -0700)
commite51217e15c3eb89d18b313dad32db1787d4f2a44
treee449f83d8a6425166a332abe71cf7d30669f5772
parent48860819e80260abae480407d0bd75dd58e70bb7
t5000: test tar files that overflow ustar headers

The ustar format only has room for 11 (or 12, depending on
some implementations) octal digits for the size and mtime of
each file. For values larger than this, we have to add pax
extended headers to specify the real data, and git does not
yet know how to do so.

Before fixing that, let's start off with some test
infrastructure, as designing portable and efficient tests
for this is non-trivial.

We want to use the system tar to check our output (because
what we really care about is interoperability), but we can't
rely on it:

  1. being able to read pax headers

  2. being able to handle huge sizes or mtimes

  3. supporting a "t" format we can parse

So as a prerequisite, we can feed the system tar a reference
tarball to make sure it can handle these features. The
reference tar here was created with:

  dd if=/dev/zero seek=64G bs=1 count=1 of=huge
  touch -d @68719476737 huge
  tar cf - --format=pax |
  head -c 2048

using GNU tar. Note that this is not a complete tarfile, but
it's enough to contain the headers we want to examine.

Likewise, we need to convince git that it has a 64GB blob to
output. Running "git add" on that 64GB file takes many
minutes of CPU, and even compressed, the result is 64MB. So
again, I pre-generated that loose object, and then took only
the first 2k of it. That should be enough to generate 2MB of
data before hitting an inflate error, which is plenty for us
to generate the tar header (and then die of SIGPIPE while
streaming the rest out).

The tests are split so that we test as much as we can even
with an uncooperative system tar. This actually catches the
current breakage (which is that we die("BUG") trying to
write the ustar header) on every system, and then on systems
where we can, we go farther and actually verify the result.

Helped-by: Robin H. Johnson <robbat2@gentoo.org>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5000-tar-tree.sh
t/t5000/19f9c8273ec45a8938e6999cb59b3ff66739902a [new file with mode: 0644]
t/t5000/huge-and-future.tar [new file with mode: 0644]