[PATCH v3] friendlier handling of overflows in archive-tar
- From
Jeff King <peff@peff.net>
- Date
- Jun 23, 2016, 23:15 UTC
- Message-ID
- <20160623231512.GA27683@sigill.intra.peff.net>
- In-Reply-To
- <20160621161604.GA17638@sigill.intra.peff.net>
This is a replacement for the jk/big-and-future-archive-tar topic. It's sufficiently rewritten that I won't bother with an interdiff, but rather just describe the changes below. Thanks to René for talking through some of the issues, and to Robin for suggesting the double-compression trick for the tests.
The important changes here are:
- the "size" fix is more localized to write_tar_entry(). This results
in shorter code, and means that if one were to somehow write an
extended header larger than 8GB, we would notice and die(), rather
than just writing a "0" (though such a thing should not be
possible). - the mtime is now written only in a single global header, rather than
once per file. I checked POSIX and this is explicitly allowed, and
of course I also checked that it works against GNU tar. - there are now tests! I tried hard to make them portable and
efficient. See the first patch for details. - the final patch is just a cleanup I noticed in the area; it could be
done independently, but I floated it to the end in case it's
controversial.The patches are:
[1/4]: t5000: test tar files that overflow ustar headers [2/4]: archive-tar: write extended headers for file sizes >= 8GB [3/4]: archive-tar: write extended headers for far-future mtime [4/4]: archive-tar: drop return value
-Peff