vendor: update archive/tar
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 13954b0a6282d919c91626a23967377c19ee7aa2)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
diff --git a/vendor.conf b/vendor.conf
index 1b80231..9ff5290 100644
--- a/vendor.conf
+++ b/vendor.conf
@@ -148,7 +148,7 @@
# archive/tar
# mkdir -p ./vendor/archive
# git clone git://github.com/tonistiigi/go-1.git ./go
-# git --git-dir ./go/.git --work-tree ./go checkout revert-prefix-ignore
+# git --git-dir ./go/.git --work-tree ./go checkout revert-prefix-ignore-1.9
# cp -a go/src/archive/tar ./vendor/archive/tar
# rm -rf ./go
# vndr
diff --git a/vendor/archive/tar/common.go b/vendor/archive/tar/common.go
index d2ae66d..d49c5c3 100644
--- a/vendor/archive/tar/common.go
+++ b/vendor/archive/tar/common.go
@@ -158,11 +158,15 @@
// sysStat, if non-nil, populates h from system-dependent fields of fi.
var sysStat func(fi os.FileInfo, h *Header) error
-// Mode constants from the tar spec.
const (
- c_ISUID = 04000 // Set uid
- c_ISGID = 02000 // Set gid
- c_ISVTX = 01000 // Save text (sticky bit)
+ // Mode constants from the USTAR spec:
+ // See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_06
+ c_ISUID = 04000 // Set uid
+ c_ISGID = 02000 // Set gid
+ c_ISVTX = 01000 // Save text (sticky bit)
+
+ // Common Unix mode constants; these are not defined in any common tar standard.
+ // Header.FileInfo understands these, but FileInfoHeader will never produce these.
c_ISDIR = 040000 // Directory
c_ISFIFO = 010000 // FIFO
c_ISREG = 0100000 // Regular file
@@ -208,30 +212,24 @@
}
switch {
case fm.IsRegular():
- h.Mode |= c_ISREG
h.Typeflag = TypeReg
h.Size = fi.Size()
case fi.IsDir():
h.Typeflag = TypeDir
- h.Mode |= c_ISDIR
h.Name += "/"
case fm&os.ModeSymlink != 0:
h.Typeflag = TypeSymlink
- h.Mode |= c_ISLNK
h.Linkname = link
case fm&os.ModeDevice != 0:
if fm&os.ModeCharDevice != 0 {
- h.Mode |= c_ISCHR
h.Typeflag = TypeChar
} else {
- h.Mode |= c_ISBLK
h.Typeflag = TypeBlock
}
case fm&os.ModeNamedPipe != 0:
h.Typeflag = TypeFifo
- h.Mode |= c_ISFIFO
case fm&os.ModeSocket != 0:
- h.Mode |= c_ISSOCK
+ return nil, fmt.Errorf("archive/tar: sockets not supported")
default:
return nil, fmt.Errorf("archive/tar: unknown file mode %v", fm)
}
diff --git a/vendor/archive/tar/writer.go b/vendor/archive/tar/writer.go
index 596fb8b..c51c243 100644
--- a/vendor/archive/tar/writer.go
+++ b/vendor/archive/tar/writer.go
@@ -121,9 +121,15 @@
needsPaxHeader := paxKeyword != paxNone && len(s) > len(b) || !isASCII(s)
if needsPaxHeader {
paxHeaders[paxKeyword] = s
- return
}
- f.formatString(b, s)
+
+ // Write string in a best-effort manner to satisfy readers that expect
+ // the field to be non-empty.
+ s = toASCII(s)
+ if len(s) > len(b) {
+ s = s[:len(b)]
+ }
+ f.formatString(b, s) // Should never error
}
var formatNumeric = func(b []byte, x int64, paxKeyword string) {
// Try octal first.