]> Cypherpunks repositories - gostls13.git/commit
archive/tar: use best effort at writing USTAR header
authorJoe Tsai <joetsai@digital-static.net>
Wed, 28 Jun 2017 00:30:39 +0000 (17:30 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Wed, 28 Jun 2017 03:09:38 +0000 (03:09 +0000)
commitc991d2ab14496789146560608c5756d5d83b35f6
tree80da40f13e9ac51cd3af0011c44655a9f388ef11
parent289a8719ce4a84cec0ed4e47037da0e82d67dcb8
archive/tar: use best effort at writing USTAR header

Prior to this change, if the Writer needed to use the PAX format, it would
output a USTAR header with an empty name. This should be okay since the PAX
specification dictates that the PAX record for "path" should override the
semantic meaning of any of the old USTAR fields.

Unfortunately, the implementation of tar on OpenBSD 6.1 is too strict with
their handling of PAX files such that they check for the validity of this
bogus field even though the PAX header is present.

To allow Go's Writer output be parsible by OpenBSD's tar utility,
we write a best-effort (ASCII-only and truncated) version of the original
file name. Note that this still fails in some edge-cases (for example,
a Chinese filename containing all non-ASCII characters). OpenBSD should really
relax their checking, as you honestly can't always expect a sensible path
to be generated when USTAR cannot handle the original path.

Fixes #20707

Change-Id: Id7d77349023d2152d7291d582cd050b6681760e4
Reviewed-on: https://go-review.googlesource.com/46914
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/archive/tar/testdata/ustar.issue12594.tar
src/archive/tar/testdata/writer-big-long.tar
src/archive/tar/writer.go