summaryrefslogtreecommitdiffstats
path: root/recipes-containers/docker/files/0002-Revert-go-updates-from-1.18.7-to-1.17.13.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-containers/docker/files/0002-Revert-go-updates-from-1.18.7-to-1.17.13.patch')
-rw-r--r--recipes-containers/docker/files/0002-Revert-go-updates-from-1.18.7-to-1.17.13.patch1201
1 files changed, 1201 insertions, 0 deletions
diff --git a/recipes-containers/docker/files/0002-Revert-go-updates-from-1.18.7-to-1.17.13.patch b/recipes-containers/docker/files/0002-Revert-go-updates-from-1.18.7-to-1.17.13.patch
new file mode 100644
index 00000000..7cacccb8
--- /dev/null
+++ b/recipes-containers/docker/files/0002-Revert-go-updates-from-1.18.7-to-1.17.13.patch
@@ -0,0 +1,1201 @@
1From 575302e9c6567b8547b308b2b0c6a07b27e3be3b Mon Sep 17 00:00:00 2001
2From: Adrian Freihofer <adrian.freihofer@siemens.com>
3Date: Sun, 4 Dec 2022 18:02:54 +0100
4Subject: [PATCH] Revert go updates from 1.18.7 to 1.17.13
5
6Upstream-Status: Inapropriate
7
8Updating this patch:
9 git revert -m 1 7d4cc78c0289edbb4727e3d50d4b130ce0f9c47e
10
11This reverts commit 7d4cc78c0289edbb4727e3d50d4b130ce0f9c47e, reversing
12changes made to 32debe0986f4516bfe17bf9122447f0c735e61b4.
13---
14 Dockerfile | 2 +-
15 Dockerfile.e2e | 2 +-
16 Dockerfile.simple | 2 +-
17 Dockerfile.windows | 2 +-
18 daemon/logger/templates/templates.go | 2 +-
19 pkg/plugins/pluginrpc-gen/template.go | 2 +-
20 vendor/archive/tar/common.go | 40 ++++----
21 vendor/archive/tar/format.go | 138 +++++++++++++-------------
22 vendor/archive/tar/fuzz_test.go | 80 ---------------
23 vendor/archive/tar/reader.go | 102 ++++++++++---------
24 vendor/archive/tar/reader_test.go | 30 +++---
25 vendor/archive/tar/stat_actime1.go | 1 +
26 vendor/archive/tar/stat_actime2.go | 1 +
27 vendor/archive/tar/strconv.go | 43 +++++---
28 vendor/archive/tar/tar_test.go | 2 +-
29 vendor/archive/tar/writer.go | 89 ++++++++---------
30 vendor/archive/tar/writer_test.go | 24 +++--
31 17 files changed, 250 insertions(+), 312 deletions(-)
32 delete mode 100644 vendor/archive/tar/fuzz_test.go
33
34diff --git a/Dockerfile b/Dockerfile
35index 9472c512a6..f3f7956414 100644
36--- a/Dockerfile
37+++ b/Dockerfile
38@@ -3,7 +3,7 @@
39 ARG CROSS="false"
40 ARG SYSTEMD="false"
41 # IMPORTANT: When updating this please note that stdlib archive/tar pkg is vendored
42-ARG GO_VERSION=1.18.7
43+ARG GO_VERSION=1.17.13
44 ARG DEBIAN_FRONTEND=noninteractive
45 ARG VPNKIT_VERSION=0.5.0
46 ARG DOCKER_BUILDTAGS="apparmor seccomp"
47diff --git a/Dockerfile.e2e b/Dockerfile.e2e
48index f92bec85b0..d0f0b08acd 100644
49--- a/Dockerfile.e2e
50+++ b/Dockerfile.e2e
51@@ -1,4 +1,4 @@
52-ARG GO_VERSION=1.18.7
53+ARG GO_VERSION=1.17.13
54
55 FROM golang:${GO_VERSION}-alpine AS base
56 ENV GO111MODULE=off
57diff --git a/Dockerfile.simple b/Dockerfile.simple
58index 8aa6d7ff94..1db20c1e35 100644
59--- a/Dockerfile.simple
60+++ b/Dockerfile.simple
61@@ -5,7 +5,7 @@
62
63 # This represents the bare minimum required to build and test Docker.
64
65-ARG GO_VERSION=1.18.7
66+ARG GO_VERSION=1.17.13
67
68 FROM golang:${GO_VERSION}-buster
69 ENV GO111MODULE=off
70diff --git a/Dockerfile.windows b/Dockerfile.windows
71index 6f8242decc..b0ee068aab 100644
72--- a/Dockerfile.windows
73+++ b/Dockerfile.windows
74@@ -165,7 +165,7 @@ FROM microsoft/windowsservercore
75 # Use PowerShell as the default shell
76 SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
77
78-ARG GO_VERSION=1.18.7
79+ARG GO_VERSION=1.17.13
80 ARG GOTESTSUM_VERSION=v1.7.0
81
82 # Environment variable notes:
83diff --git a/daemon/logger/templates/templates.go b/daemon/logger/templates/templates.go
84index d8b4ce5d85..ab76d0f1c2 100644
85--- a/daemon/logger/templates/templates.go
86+++ b/daemon/logger/templates/templates.go
87@@ -20,7 +20,7 @@ var basicFunctions = template.FuncMap{
88 },
89 "split": strings.Split,
90 "join": strings.Join,
91- "title": strings.Title, //nolint:staticcheck // SA1019: strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
92+ "title": strings.Title,
93 "lower": strings.ToLower,
94 "upper": strings.ToUpper,
95 "pad": padWithSpace,
96diff --git a/pkg/plugins/pluginrpc-gen/template.go b/pkg/plugins/pluginrpc-gen/template.go
97index c34a5add11..50ed9293c1 100644
98--- a/pkg/plugins/pluginrpc-gen/template.go
99+++ b/pkg/plugins/pluginrpc-gen/template.go
100@@ -64,7 +64,7 @@ func title(s string) string {
101 if strings.ToLower(s) == "id" {
102 return "ID"
103 }
104- return strings.Title(s) //nolint:staticcheck // SA1019: strings.Title is deprecated: The rule Title uses for word boundaries does not handle Unicode punctuation properly. Use golang.org/x/text/cases instead.
105+ return strings.Title(s)
106 }
107
108 var generatedTempl = template.Must(template.New("rpc_cient").Funcs(templFuncs).Parse(`
109diff --git a/vendor/archive/tar/common.go b/vendor/archive/tar/common.go
110index f6d701d925..8706ede431 100644
111--- a/vendor/archive/tar/common.go
112+++ b/vendor/archive/tar/common.go
113@@ -319,10 +319,10 @@ func invertSparseEntries(src []sparseEntry, size int64) []sparseEntry {
114 // fileState tracks the number of logical (includes sparse holes) and physical
115 // (actual in tar archive) bytes remaining for the current file.
116 //
117-// Invariant: logicalRemaining >= physicalRemaining
118+// Invariant: LogicalRemaining >= PhysicalRemaining
119 type fileState interface {
120- logicalRemaining() int64
121- physicalRemaining() int64
122+ LogicalRemaining() int64
123+ PhysicalRemaining() int64
124 }
125
126 // allowedFormats determines which formats can be used.
127@@ -416,22 +416,22 @@ func (h Header) allowedFormats() (format Format, paxHdrs map[string]string, err
128
129 // Check basic fields.
130 var blk block
131- v7 := blk.toV7()
132- ustar := blk.toUSTAR()
133- gnu := blk.toGNU()
134- verifyString(h.Name, len(v7.name()), "Name", paxPath)
135- verifyString(h.Linkname, len(v7.linkName()), "Linkname", paxLinkpath)
136- verifyString(h.Uname, len(ustar.userName()), "Uname", paxUname)
137- verifyString(h.Gname, len(ustar.groupName()), "Gname", paxGname)
138- verifyNumeric(h.Mode, len(v7.mode()), "Mode", paxNone)
139- verifyNumeric(int64(h.Uid), len(v7.uid()), "Uid", paxUid)
140- verifyNumeric(int64(h.Gid), len(v7.gid()), "Gid", paxGid)
141- verifyNumeric(h.Size, len(v7.size()), "Size", paxSize)
142- verifyNumeric(h.Devmajor, len(ustar.devMajor()), "Devmajor", paxNone)
143- verifyNumeric(h.Devminor, len(ustar.devMinor()), "Devminor", paxNone)
144- verifyTime(h.ModTime, len(v7.modTime()), "ModTime", paxMtime)
145- verifyTime(h.AccessTime, len(gnu.accessTime()), "AccessTime", paxAtime)
146- verifyTime(h.ChangeTime, len(gnu.changeTime()), "ChangeTime", paxCtime)
147+ v7 := blk.V7()
148+ ustar := blk.USTAR()
149+ gnu := blk.GNU()
150+ verifyString(h.Name, len(v7.Name()), "Name", paxPath)
151+ verifyString(h.Linkname, len(v7.LinkName()), "Linkname", paxLinkpath)
152+ verifyString(h.Uname, len(ustar.UserName()), "Uname", paxUname)
153+ verifyString(h.Gname, len(ustar.GroupName()), "Gname", paxGname)
154+ verifyNumeric(h.Mode, len(v7.Mode()), "Mode", paxNone)
155+ verifyNumeric(int64(h.Uid), len(v7.UID()), "Uid", paxUid)
156+ verifyNumeric(int64(h.Gid), len(v7.GID()), "Gid", paxGid)
157+ verifyNumeric(h.Size, len(v7.Size()), "Size", paxSize)
158+ verifyNumeric(h.Devmajor, len(ustar.DevMajor()), "Devmajor", paxNone)
159+ verifyNumeric(h.Devminor, len(ustar.DevMinor()), "Devminor", paxNone)
160+ verifyTime(h.ModTime, len(v7.ModTime()), "ModTime", paxMtime)
161+ verifyTime(h.AccessTime, len(gnu.AccessTime()), "AccessTime", paxAtime)
162+ verifyTime(h.ChangeTime, len(gnu.ChangeTime()), "ChangeTime", paxCtime)
163
164 // Check for header-only types.
165 var whyOnlyPAX, whyOnlyGNU string
166@@ -541,7 +541,7 @@ type headerFileInfo struct {
167 func (fi headerFileInfo) Size() int64 { return fi.h.Size }
168 func (fi headerFileInfo) IsDir() bool { return fi.Mode().IsDir() }
169 func (fi headerFileInfo) ModTime() time.Time { return fi.h.ModTime }
170-func (fi headerFileInfo) Sys() any { return fi.h }
171+func (fi headerFileInfo) Sys() interface{} { return fi.h }
172
173 // Name returns the base name of the file.
174 func (fi headerFileInfo) Name() string {
175diff --git a/vendor/archive/tar/format.go b/vendor/archive/tar/format.go
176index 8898c438b5..6642364de1 100644
177--- a/vendor/archive/tar/format.go
178+++ b/vendor/archive/tar/format.go
179@@ -160,28 +160,28 @@ var zeroBlock block
180 type block [blockSize]byte
181
182 // Convert block to any number of formats.
183-func (b *block) toV7() *headerV7 { return (*headerV7)(b) }
184-func (b *block) toGNU() *headerGNU { return (*headerGNU)(b) }
185-func (b *block) toSTAR() *headerSTAR { return (*headerSTAR)(b) }
186-func (b *block) toUSTAR() *headerUSTAR { return (*headerUSTAR)(b) }
187-func (b *block) toSparse() sparseArray { return sparseArray(b[:]) }
188+func (b *block) V7() *headerV7 { return (*headerV7)(b) }
189+func (b *block) GNU() *headerGNU { return (*headerGNU)(b) }
190+func (b *block) STAR() *headerSTAR { return (*headerSTAR)(b) }
191+func (b *block) USTAR() *headerUSTAR { return (*headerUSTAR)(b) }
192+func (b *block) Sparse() sparseArray { return sparseArray(b[:]) }
193
194 // GetFormat checks that the block is a valid tar header based on the checksum.
195 // It then attempts to guess the specific format based on magic values.
196 // If the checksum fails, then FormatUnknown is returned.
197-func (b *block) getFormat() Format {
198+func (b *block) GetFormat() Format {
199 // Verify checksum.
200 var p parser
201- value := p.parseOctal(b.toV7().chksum())
202- chksum1, chksum2 := b.computeChecksum()
203+ value := p.parseOctal(b.V7().Chksum())
204+ chksum1, chksum2 := b.ComputeChecksum()
205 if p.err != nil || (value != chksum1 && value != chksum2) {
206 return FormatUnknown
207 }
208
209 // Guess the magic values.
210- magic := string(b.toUSTAR().magic())
211- version := string(b.toUSTAR().version())
212- trailer := string(b.toSTAR().trailer())
213+ magic := string(b.USTAR().Magic())
214+ version := string(b.USTAR().Version())
215+ trailer := string(b.STAR().Trailer())
216 switch {
217 case magic == magicUSTAR && trailer == trailerSTAR:
218 return formatSTAR
219@@ -194,23 +194,23 @@ func (b *block) getFormat() Format {
220 }
221 }
222
223-// setFormat writes the magic values necessary for specified format
224+// SetFormat writes the magic values necessary for specified format
225 // and then updates the checksum accordingly.
226-func (b *block) setFormat(format Format) {
227+func (b *block) SetFormat(format Format) {
228 // Set the magic values.
229 switch {
230 case format.has(formatV7):
231 // Do nothing.
232 case format.has(FormatGNU):
233- copy(b.toGNU().magic(), magicGNU)
234- copy(b.toGNU().version(), versionGNU)
235+ copy(b.GNU().Magic(), magicGNU)
236+ copy(b.GNU().Version(), versionGNU)
237 case format.has(formatSTAR):
238- copy(b.toSTAR().magic(), magicUSTAR)
239- copy(b.toSTAR().version(), versionUSTAR)
240- copy(b.toSTAR().trailer(), trailerSTAR)
241+ copy(b.STAR().Magic(), magicUSTAR)
242+ copy(b.STAR().Version(), versionUSTAR)
243+ copy(b.STAR().Trailer(), trailerSTAR)
244 case format.has(FormatUSTAR | FormatPAX):
245- copy(b.toUSTAR().magic(), magicUSTAR)
246- copy(b.toUSTAR().version(), versionUSTAR)
247+ copy(b.USTAR().Magic(), magicUSTAR)
248+ copy(b.USTAR().Version(), versionUSTAR)
249 default:
250 panic("invalid format")
251 }
252@@ -218,17 +218,17 @@ func (b *block) setFormat(format Format) {
253 // Update checksum.
254 // This field is special in that it is terminated by a NULL then space.
255 var f formatter
256- field := b.toV7().chksum()
257- chksum, _ := b.computeChecksum() // Possible values are 256..128776
258+ field := b.V7().Chksum()
259+ chksum, _ := b.ComputeChecksum() // Possible values are 256..128776
260 f.formatOctal(field[:7], chksum) // Never fails since 128776 < 262143
261 field[7] = ' '
262 }
263
264-// computeChecksum computes the checksum for the header block.
265+// ComputeChecksum computes the checksum for the header block.
266 // POSIX specifies a sum of the unsigned byte values, but the Sun tar used
267 // signed byte values.
268 // We compute and return both.
269-func (b *block) computeChecksum() (unsigned, signed int64) {
270+func (b *block) ComputeChecksum() (unsigned, signed int64) {
271 for i, c := range b {
272 if 148 <= i && i < 156 {
273 c = ' ' // Treat the checksum field itself as all spaces.
274@@ -240,68 +240,68 @@ func (b *block) computeChecksum() (unsigned, signed int64) {
275 }
276
277 // Reset clears the block with all zeros.
278-func (b *block) reset() {
279+func (b *block) Reset() {
280 *b = block{}
281 }
282
283 type headerV7 [blockSize]byte
284
285-func (h *headerV7) name() []byte { return h[000:][:100] }
286-func (h *headerV7) mode() []byte { return h[100:][:8] }
287-func (h *headerV7) uid() []byte { return h[108:][:8] }
288-func (h *headerV7) gid() []byte { return h[116:][:8] }
289-func (h *headerV7) size() []byte { return h[124:][:12] }
290-func (h *headerV7) modTime() []byte { return h[136:][:12] }
291-func (h *headerV7) chksum() []byte { return h[148:][:8] }
292-func (h *headerV7) typeFlag() []byte { return h[156:][:1] }
293-func (h *headerV7) linkName() []byte { return h[157:][:100] }
294+func (h *headerV7) Name() []byte { return h[000:][:100] }
295+func (h *headerV7) Mode() []byte { return h[100:][:8] }
296+func (h *headerV7) UID() []byte { return h[108:][:8] }
297+func (h *headerV7) GID() []byte { return h[116:][:8] }
298+func (h *headerV7) Size() []byte { return h[124:][:12] }
299+func (h *headerV7) ModTime() []byte { return h[136:][:12] }
300+func (h *headerV7) Chksum() []byte { return h[148:][:8] }
301+func (h *headerV7) TypeFlag() []byte { return h[156:][:1] }
302+func (h *headerV7) LinkName() []byte { return h[157:][:100] }
303
304 type headerGNU [blockSize]byte
305
306-func (h *headerGNU) v7() *headerV7 { return (*headerV7)(h) }
307-func (h *headerGNU) magic() []byte { return h[257:][:6] }
308-func (h *headerGNU) version() []byte { return h[263:][:2] }
309-func (h *headerGNU) userName() []byte { return h[265:][:32] }
310-func (h *headerGNU) groupName() []byte { return h[297:][:32] }
311-func (h *headerGNU) devMajor() []byte { return h[329:][:8] }
312-func (h *headerGNU) devMinor() []byte { return h[337:][:8] }
313-func (h *headerGNU) accessTime() []byte { return h[345:][:12] }
314-func (h *headerGNU) changeTime() []byte { return h[357:][:12] }
315-func (h *headerGNU) sparse() sparseArray { return sparseArray(h[386:][:24*4+1]) }
316-func (h *headerGNU) realSize() []byte { return h[483:][:12] }
317+func (h *headerGNU) V7() *headerV7 { return (*headerV7)(h) }
318+func (h *headerGNU) Magic() []byte { return h[257:][:6] }
319+func (h *headerGNU) Version() []byte { return h[263:][:2] }
320+func (h *headerGNU) UserName() []byte { return h[265:][:32] }
321+func (h *headerGNU) GroupName() []byte { return h[297:][:32] }
322+func (h *headerGNU) DevMajor() []byte { return h[329:][:8] }
323+func (h *headerGNU) DevMinor() []byte { return h[337:][:8] }
324+func (h *headerGNU) AccessTime() []byte { return h[345:][:12] }
325+func (h *headerGNU) ChangeTime() []byte { return h[357:][:12] }
326+func (h *headerGNU) Sparse() sparseArray { return sparseArray(h[386:][:24*4+1]) }
327+func (h *headerGNU) RealSize() []byte { return h[483:][:12] }
328
329 type headerSTAR [blockSize]byte
330
331-func (h *headerSTAR) v7() *headerV7 { return (*headerV7)(h) }
332-func (h *headerSTAR) magic() []byte { return h[257:][:6] }
333-func (h *headerSTAR) version() []byte { return h[263:][:2] }
334-func (h *headerSTAR) userName() []byte { return h[265:][:32] }
335-func (h *headerSTAR) groupName() []byte { return h[297:][:32] }
336-func (h *headerSTAR) devMajor() []byte { return h[329:][:8] }
337-func (h *headerSTAR) devMinor() []byte { return h[337:][:8] }
338-func (h *headerSTAR) prefix() []byte { return h[345:][:131] }
339-func (h *headerSTAR) accessTime() []byte { return h[476:][:12] }
340-func (h *headerSTAR) changeTime() []byte { return h[488:][:12] }
341-func (h *headerSTAR) trailer() []byte { return h[508:][:4] }
342+func (h *headerSTAR) V7() *headerV7 { return (*headerV7)(h) }
343+func (h *headerSTAR) Magic() []byte { return h[257:][:6] }
344+func (h *headerSTAR) Version() []byte { return h[263:][:2] }
345+func (h *headerSTAR) UserName() []byte { return h[265:][:32] }
346+func (h *headerSTAR) GroupName() []byte { return h[297:][:32] }
347+func (h *headerSTAR) DevMajor() []byte { return h[329:][:8] }
348+func (h *headerSTAR) DevMinor() []byte { return h[337:][:8] }
349+func (h *headerSTAR) Prefix() []byte { return h[345:][:131] }
350+func (h *headerSTAR) AccessTime() []byte { return h[476:][:12] }
351+func (h *headerSTAR) ChangeTime() []byte { return h[488:][:12] }
352+func (h *headerSTAR) Trailer() []byte { return h[508:][:4] }
353
354 type headerUSTAR [blockSize]byte
355
356-func (h *headerUSTAR) v7() *headerV7 { return (*headerV7)(h) }
357-func (h *headerUSTAR) magic() []byte { return h[257:][:6] }
358-func (h *headerUSTAR) version() []byte { return h[263:][:2] }
359-func (h *headerUSTAR) userName() []byte { return h[265:][:32] }
360-func (h *headerUSTAR) groupName() []byte { return h[297:][:32] }
361-func (h *headerUSTAR) devMajor() []byte { return h[329:][:8] }
362-func (h *headerUSTAR) devMinor() []byte { return h[337:][:8] }
363-func (h *headerUSTAR) prefix() []byte { return h[345:][:155] }
364+func (h *headerUSTAR) V7() *headerV7 { return (*headerV7)(h) }
365+func (h *headerUSTAR) Magic() []byte { return h[257:][:6] }
366+func (h *headerUSTAR) Version() []byte { return h[263:][:2] }
367+func (h *headerUSTAR) UserName() []byte { return h[265:][:32] }
368+func (h *headerUSTAR) GroupName() []byte { return h[297:][:32] }
369+func (h *headerUSTAR) DevMajor() []byte { return h[329:][:8] }
370+func (h *headerUSTAR) DevMinor() []byte { return h[337:][:8] }
371+func (h *headerUSTAR) Prefix() []byte { return h[345:][:155] }
372
373 type sparseArray []byte
374
375-func (s sparseArray) entry(i int) sparseElem { return sparseElem(s[i*24:]) }
376-func (s sparseArray) isExtended() []byte { return s[24*s.maxEntries():][:1] }
377-func (s sparseArray) maxEntries() int { return len(s) / 24 }
378+func (s sparseArray) Entry(i int) sparseElem { return sparseElem(s[i*24:]) }
379+func (s sparseArray) IsExtended() []byte { return s[24*s.MaxEntries():][:1] }
380+func (s sparseArray) MaxEntries() int { return len(s) / 24 }
381
382 type sparseElem []byte
383
384-func (s sparseElem) offset() []byte { return s[00:][:12] }
385-func (s sparseElem) length() []byte { return s[12:][:12] }
386+func (s sparseElem) Offset() []byte { return s[00:][:12] }
387+func (s sparseElem) Length() []byte { return s[12:][:12] }
388diff --git a/vendor/archive/tar/fuzz_test.go b/vendor/archive/tar/fuzz_test.go
389deleted file mode 100644
390index e73e0d2609..0000000000
391--- a/vendor/archive/tar/fuzz_test.go
392+++ /dev/null
393@@ -1,80 +0,0 @@
394-// Copyright 2021 The Go Authors. All rights reserved.
395-// Use of this source code is governed by a BSD-style
396-// license that can be found in the LICENSE file.
397-
398-package tar
399-
400-import (
401- "bytes"
402- "io"
403- "testing"
404-)
405-
406-func FuzzReader(f *testing.F) {
407- b := bytes.NewBuffer(nil)
408- w := NewWriter(b)
409- inp := []byte("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
410- err := w.WriteHeader(&Header{
411- Name: "lorem.txt",
412- Mode: 0600,
413- Size: int64(len(inp)),
414- })
415- if err != nil {
416- f.Fatalf("failed to create writer: %s", err)
417- }
418- _, err = w.Write(inp)
419- if err != nil {
420- f.Fatalf("failed to write file to archive: %s", err)
421- }
422- if err := w.Close(); err != nil {
423- f.Fatalf("failed to write archive: %s", err)
424- }
425- f.Add(b.Bytes())
426-
427- f.Fuzz(func(t *testing.T, b []byte) {
428- r := NewReader(bytes.NewReader(b))
429- type file struct {
430- header *Header
431- content []byte
432- }
433- files := []file{}
434- for {
435- hdr, err := r.Next()
436- if err == io.EOF {
437- break
438- }
439- if err != nil {
440- return
441- }
442- buf := bytes.NewBuffer(nil)
443- if _, err := io.Copy(buf, r); err != nil {
444- continue
445- }
446- files = append(files, file{header: hdr, content: buf.Bytes()})
447- }
448-
449- // If we were unable to read anything out of the archive don't
450- // bother trying to roundtrip it.
451- if len(files) == 0 {
452- return
453- }
454-
455- out := bytes.NewBuffer(nil)
456- w := NewWriter(out)
457- for _, f := range files {
458- if err := w.WriteHeader(f.header); err != nil {
459- t.Fatalf("unable to write previously parsed header: %s", err)
460- }
461- if _, err := w.Write(f.content); err != nil {
462- t.Fatalf("unable to write previously parsed content: %s", err)
463- }
464- }
465- if err := w.Close(); err != nil {
466- t.Fatalf("Unable to write archive: %s", err)
467- }
468-
469- // TODO: We may want to check if the archive roundtrips. This would require
470- // taking into account addition of the two zero trailer blocks that Writer.Close
471- // appends.
472- })
473-}
474diff --git a/vendor/archive/tar/reader.go b/vendor/archive/tar/reader.go
475index 45848304ed..ca32bdea1f 100644
476--- a/vendor/archive/tar/reader.go
477+++ b/vendor/archive/tar/reader.go
478@@ -65,7 +65,7 @@ func (tr *Reader) next() (*Header, error) {
479 format := FormatUSTAR | FormatPAX | FormatGNU
480 for {
481 // Discard the remainder of the file and any padding.
482- if err := discard(tr.r, tr.curr.physicalRemaining()); err != nil {
483+ if err := discard(tr.r, tr.curr.PhysicalRemaining()); err != nil {
484 return nil, err
485 }
486 if _, err := tryReadFull(tr.r, tr.blk[:tr.pad]); err != nil {
487@@ -355,7 +355,7 @@ func (tr *Reader) readHeader() (*Header, *block, error) {
488 }
489
490 // Verify the header matches a known format.
491- format := tr.blk.getFormat()
492+ format := tr.blk.GetFormat()
493 if format == FormatUnknown {
494 return nil, nil, ErrHeader
495 }
496@@ -364,30 +364,30 @@ func (tr *Reader) readHeader() (*Header, *block, error) {
497 hdr := new(Header)
498
499 // Unpack the V7 header.
500- v7 := tr.blk.toV7()
501- hdr.Typeflag = v7.typeFlag()[0]
502- hdr.Name = p.parseString(v7.name())
503- hdr.Linkname = p.parseString(v7.linkName())
504- hdr.Size = p.parseNumeric(v7.size())
505- hdr.Mode = p.parseNumeric(v7.mode())
506- hdr.Uid = int(p.parseNumeric(v7.uid()))
507- hdr.Gid = int(p.parseNumeric(v7.gid()))
508- hdr.ModTime = time.Unix(p.parseNumeric(v7.modTime()), 0)
509+ v7 := tr.blk.V7()
510+ hdr.Typeflag = v7.TypeFlag()[0]
511+ hdr.Name = p.parseString(v7.Name())
512+ hdr.Linkname = p.parseString(v7.LinkName())
513+ hdr.Size = p.parseNumeric(v7.Size())
514+ hdr.Mode = p.parseNumeric(v7.Mode())
515+ hdr.Uid = int(p.parseNumeric(v7.UID()))
516+ hdr.Gid = int(p.parseNumeric(v7.GID()))
517+ hdr.ModTime = time.Unix(p.parseNumeric(v7.ModTime()), 0)
518
519 // Unpack format specific fields.
520 if format > formatV7 {
521- ustar := tr.blk.toUSTAR()
522- hdr.Uname = p.parseString(ustar.userName())
523- hdr.Gname = p.parseString(ustar.groupName())
524- hdr.Devmajor = p.parseNumeric(ustar.devMajor())
525- hdr.Devminor = p.parseNumeric(ustar.devMinor())
526+ ustar := tr.blk.USTAR()
527+ hdr.Uname = p.parseString(ustar.UserName())
528+ hdr.Gname = p.parseString(ustar.GroupName())
529+ hdr.Devmajor = p.parseNumeric(ustar.DevMajor())
530+ hdr.Devminor = p.parseNumeric(ustar.DevMinor())
531
532 var prefix string
533 switch {
534 case format.has(FormatUSTAR | FormatPAX):
535 hdr.Format = format
536- ustar := tr.blk.toUSTAR()
537- prefix = p.parseString(ustar.prefix())
538+ ustar := tr.blk.USTAR()
539+ prefix = p.parseString(ustar.Prefix())
540
541 // For Format detection, check if block is properly formatted since
542 // the parser is more liberal than what USTAR actually permits.
543@@ -396,23 +396,23 @@ func (tr *Reader) readHeader() (*Header, *block, error) {
544 hdr.Format = FormatUnknown // Non-ASCII characters in block.
545 }
546 nul := func(b []byte) bool { return int(b[len(b)-1]) == 0 }
547- if !(nul(v7.size()) && nul(v7.mode()) && nul(v7.uid()) && nul(v7.gid()) &&
548- nul(v7.modTime()) && nul(ustar.devMajor()) && nul(ustar.devMinor())) {
549+ if !(nul(v7.Size()) && nul(v7.Mode()) && nul(v7.UID()) && nul(v7.GID()) &&
550+ nul(v7.ModTime()) && nul(ustar.DevMajor()) && nul(ustar.DevMinor())) {
551 hdr.Format = FormatUnknown // Numeric fields must end in NUL
552 }
553 case format.has(formatSTAR):
554- star := tr.blk.toSTAR()
555- prefix = p.parseString(star.prefix())
556- hdr.AccessTime = time.Unix(p.parseNumeric(star.accessTime()), 0)
557- hdr.ChangeTime = time.Unix(p.parseNumeric(star.changeTime()), 0)
558+ star := tr.blk.STAR()
559+ prefix = p.parseString(star.Prefix())
560+ hdr.AccessTime = time.Unix(p.parseNumeric(star.AccessTime()), 0)
561+ hdr.ChangeTime = time.Unix(p.parseNumeric(star.ChangeTime()), 0)
562 case format.has(FormatGNU):
563 hdr.Format = format
564 var p2 parser
565- gnu := tr.blk.toGNU()
566- if b := gnu.accessTime(); b[0] != 0 {
567+ gnu := tr.blk.GNU()
568+ if b := gnu.AccessTime(); b[0] != 0 {
569 hdr.AccessTime = time.Unix(p2.parseNumeric(b), 0)
570 }
571- if b := gnu.changeTime(); b[0] != 0 {
572+ if b := gnu.ChangeTime(); b[0] != 0 {
573 hdr.ChangeTime = time.Unix(p2.parseNumeric(b), 0)
574 }
575
576@@ -439,8 +439,8 @@ func (tr *Reader) readHeader() (*Header, *block, error) {
577 // See https://golang.org/issues/21005
578 if p2.err != nil {
579 hdr.AccessTime, hdr.ChangeTime = time.Time{}, time.Time{}
580- ustar := tr.blk.toUSTAR()
581- if s := p.parseString(ustar.prefix()); isASCII(s) {
582+ ustar := tr.blk.USTAR()
583+ if s := p.parseString(ustar.Prefix()); isASCII(s) {
584 prefix = s
585 }
586 hdr.Format = FormatUnknown // Buggy file is not GNU
587@@ -465,38 +465,38 @@ func (tr *Reader) readOldGNUSparseMap(hdr *Header, blk *block) (sparseDatas, err
588 // Make sure that the input format is GNU.
589 // Unfortunately, the STAR format also has a sparse header format that uses
590 // the same type flag but has a completely different layout.
591- if blk.getFormat() != FormatGNU {
592+ if blk.GetFormat() != FormatGNU {
593 return nil, ErrHeader
594 }
595 hdr.Format.mayOnlyBe(FormatGNU)
596
597 var p parser
598- hdr.Size = p.parseNumeric(blk.toGNU().realSize())
599+ hdr.Size = p.parseNumeric(blk.GNU().RealSize())
600 if p.err != nil {
601 return nil, p.err
602 }
603- s := blk.toGNU().sparse()
604- spd := make(sparseDatas, 0, s.maxEntries())
605+ s := blk.GNU().Sparse()
606+ spd := make(sparseDatas, 0, s.MaxEntries())
607 for {
608- for i := 0; i < s.maxEntries(); i++ {
609+ for i := 0; i < s.MaxEntries(); i++ {
610 // This termination condition is identical to GNU and BSD tar.
611- if s.entry(i).offset()[0] == 0x00 {
612+ if s.Entry(i).Offset()[0] == 0x00 {
613 break // Don't return, need to process extended headers (even if empty)
614 }
615- offset := p.parseNumeric(s.entry(i).offset())
616- length := p.parseNumeric(s.entry(i).length())
617+ offset := p.parseNumeric(s.Entry(i).Offset())
618+ length := p.parseNumeric(s.Entry(i).Length())
619 if p.err != nil {
620 return nil, p.err
621 }
622 spd = append(spd, sparseEntry{Offset: offset, Length: length})
623 }
624
625- if s.isExtended()[0] > 0 {
626+ if s.IsExtended()[0] > 0 {
627 // There are more entries. Read an extension header and parse its entries.
628 if _, err := mustReadFull(tr.r, blk[:]); err != nil {
629 return nil, err
630 }
631- s = blk.toSparse()
632+ s = blk.Sparse()
633 continue
634 }
635 return spd, nil // Done
636@@ -678,13 +678,11 @@ func (fr *regFileReader) WriteTo(w io.Writer) (int64, error) {
637 return io.Copy(w, struct{ io.Reader }{fr})
638 }
639
640-// logicalRemaining implements fileState.logicalRemaining.
641-func (fr regFileReader) logicalRemaining() int64 {
642+func (fr regFileReader) LogicalRemaining() int64 {
643 return fr.nb
644 }
645
646-// logicalRemaining implements fileState.physicalRemaining.
647-func (fr regFileReader) physicalRemaining() int64 {
648+func (fr regFileReader) PhysicalRemaining() int64 {
649 return fr.nb
650 }
651
652@@ -696,9 +694,9 @@ type sparseFileReader struct {
653 }
654
655 func (sr *sparseFileReader) Read(b []byte) (n int, err error) {
656- finished := int64(len(b)) >= sr.logicalRemaining()
657+ finished := int64(len(b)) >= sr.LogicalRemaining()
658 if finished {
659- b = b[:sr.logicalRemaining()]
660+ b = b[:sr.LogicalRemaining()]
661 }
662
663 b0 := b
664@@ -726,7 +724,7 @@ func (sr *sparseFileReader) Read(b []byte) (n int, err error) {
665 return n, errMissData // Less data in dense file than sparse file
666 case err != nil:
667 return n, err
668- case sr.logicalRemaining() == 0 && sr.physicalRemaining() > 0:
669+ case sr.LogicalRemaining() == 0 && sr.PhysicalRemaining() > 0:
670 return n, errUnrefData // More data in dense file than sparse file
671 case finished:
672 return n, io.EOF
673@@ -748,7 +746,7 @@ func (sr *sparseFileReader) WriteTo(w io.Writer) (n int64, err error) {
674
675 var writeLastByte bool
676 pos0 := sr.pos
677- for sr.logicalRemaining() > 0 && !writeLastByte && err == nil {
678+ for sr.LogicalRemaining() > 0 && !writeLastByte && err == nil {
679 var nf int64 // Size of fragment
680 holeStart, holeEnd := sr.sp[0].Offset, sr.sp[0].endOffset()
681 if sr.pos < holeStart { // In a data fragment
682@@ -756,7 +754,7 @@ func (sr *sparseFileReader) WriteTo(w io.Writer) (n int64, err error) {
683 nf, err = io.CopyN(ws, sr.fr, nf)
684 } else { // In a hole fragment
685 nf = holeEnd - sr.pos
686- if sr.physicalRemaining() == 0 {
687+ if sr.PhysicalRemaining() == 0 {
688 writeLastByte = true
689 nf--
690 }
691@@ -781,18 +779,18 @@ func (sr *sparseFileReader) WriteTo(w io.Writer) (n int64, err error) {
692 return n, errMissData // Less data in dense file than sparse file
693 case err != nil:
694 return n, err
695- case sr.logicalRemaining() == 0 && sr.physicalRemaining() > 0:
696+ case sr.LogicalRemaining() == 0 && sr.PhysicalRemaining() > 0:
697 return n, errUnrefData // More data in dense file than sparse file
698 default:
699 return n, nil
700 }
701 }
702
703-func (sr sparseFileReader) logicalRemaining() int64 {
704+func (sr sparseFileReader) LogicalRemaining() int64 {
705 return sr.sp[len(sr.sp)-1].endOffset() - sr.pos
706 }
707-func (sr sparseFileReader) physicalRemaining() int64 {
708- return sr.fr.physicalRemaining()
709+func (sr sparseFileReader) PhysicalRemaining() int64 {
710+ return sr.fr.PhysicalRemaining()
711 }
712
713 type zeroReader struct{}
714diff --git a/vendor/archive/tar/reader_test.go b/vendor/archive/tar/reader_test.go
715index 140c736429..5a644a43a4 100644
716--- a/vendor/archive/tar/reader_test.go
717+++ b/vendor/archive/tar/reader_test.go
718@@ -1030,12 +1030,12 @@ func TestParsePAX(t *testing.T) {
719
720 func TestReadOldGNUSparseMap(t *testing.T) {
721 populateSparseMap := func(sa sparseArray, sps []string) []string {
722- for i := 0; len(sps) > 0 && i < sa.maxEntries(); i++ {
723- copy(sa.entry(i), sps[0])
724+ for i := 0; len(sps) > 0 && i < sa.MaxEntries(); i++ {
725+ copy(sa.Entry(i), sps[0])
726 sps = sps[1:]
727 }
728 if len(sps) > 0 {
729- copy(sa.isExtended(), "\x80")
730+ copy(sa.IsExtended(), "\x80")
731 }
732 return sps
733 }
734@@ -1043,19 +1043,19 @@ func TestReadOldGNUSparseMap(t *testing.T) {
735 makeInput := func(format Format, size string, sps ...string) (out []byte) {
736 // Write the initial GNU header.
737 var blk block
738- gnu := blk.toGNU()
739- sparse := gnu.sparse()
740- copy(gnu.realSize(), size)
741+ gnu := blk.GNU()
742+ sparse := gnu.Sparse()
743+ copy(gnu.RealSize(), size)
744 sps = populateSparseMap(sparse, sps)
745 if format != FormatUnknown {
746- blk.setFormat(format)
747+ blk.SetFormat(format)
748 }
749 out = append(out, blk[:]...)
750
751 // Write extended sparse blocks.
752 for len(sps) > 0 {
753 var blk block
754- sps = populateSparseMap(blk.toSparse(), sps)
755+ sps = populateSparseMap(blk.Sparse(), sps)
756 out = append(out, blk[:]...)
757 }
758 return out
759@@ -1368,11 +1368,11 @@ func TestFileReader(t *testing.T) {
760 wantCnt int64
761 wantErr error
762 }
763- testRemaining struct { // logicalRemaining() == wantLCnt, physicalRemaining() == wantPCnt
764+ testRemaining struct { // LogicalRemaining() == wantLCnt, PhysicalRemaining() == wantPCnt
765 wantLCnt int64
766 wantPCnt int64
767 }
768- testFnc any // testRead | testWriteTo | testRemaining
769+ testFnc interface{} // testRead | testWriteTo | testRemaining
770 )
771
772 type (
773@@ -1385,7 +1385,7 @@ func TestFileReader(t *testing.T) {
774 spd sparseDatas
775 size int64
776 }
777- fileMaker any // makeReg | makeSparse
778+ fileMaker interface{} // makeReg | makeSparse
779 )
780
781 vectors := []struct {
782@@ -1605,11 +1605,11 @@ func TestFileReader(t *testing.T) {
783 t.Errorf("test %d.%d, expected %d more operations", i, j, len(f.ops))
784 }
785 case testRemaining:
786- if got := fr.logicalRemaining(); got != tf.wantLCnt {
787- t.Errorf("test %d.%d, logicalRemaining() = %d, want %d", i, j, got, tf.wantLCnt)
788+ if got := fr.LogicalRemaining(); got != tf.wantLCnt {
789+ t.Errorf("test %d.%d, LogicalRemaining() = %d, want %d", i, j, got, tf.wantLCnt)
790 }
791- if got := fr.physicalRemaining(); got != tf.wantPCnt {
792- t.Errorf("test %d.%d, physicalRemaining() = %d, want %d", i, j, got, tf.wantPCnt)
793+ if got := fr.PhysicalRemaining(); got != tf.wantPCnt {
794+ t.Errorf("test %d.%d, PhysicalRemaining() = %d, want %d", i, j, got, tf.wantPCnt)
795 }
796 default:
797 t.Fatalf("test %d.%d, unknown test operation: %T", i, j, tf)
798diff --git a/vendor/archive/tar/stat_actime1.go b/vendor/archive/tar/stat_actime1.go
799index c4c2480fee..4fdf2a04b3 100644
800--- a/vendor/archive/tar/stat_actime1.go
801+++ b/vendor/archive/tar/stat_actime1.go
802@@ -3,6 +3,7 @@
803 // license that can be found in the LICENSE file.
804
805 //go:build aix || linux || dragonfly || openbsd || solaris
806+// +build aix linux dragonfly openbsd solaris
807
808 package tar
809
810diff --git a/vendor/archive/tar/stat_actime2.go b/vendor/archive/tar/stat_actime2.go
811index f76d6be220..5a9a35cbb4 100644
812--- a/vendor/archive/tar/stat_actime2.go
813+++ b/vendor/archive/tar/stat_actime2.go
814@@ -3,6 +3,7 @@
815 // license that can be found in the LICENSE file.
816
817 //go:build darwin || freebsd || netbsd
818+// +build darwin freebsd netbsd
819
820 package tar
821
822diff --git a/vendor/archive/tar/strconv.go b/vendor/archive/tar/strconv.go
823index ac3196370e..fde45c9dbf 100644
824--- a/vendor/archive/tar/strconv.go
825+++ b/vendor/archive/tar/strconv.go
826@@ -14,7 +14,7 @@ import (
827
828 // hasNUL reports whether the NUL character exists within s.
829 func hasNUL(s string) bool {
830- return strings.Contains(s, "\x00")
831+ return strings.IndexByte(s, 0) >= 0
832 }
833
834 // isASCII reports whether the input is an ASCII C-style string.
835@@ -201,7 +201,10 @@ func parsePAXTime(s string) (time.Time, error) {
836 const maxNanoSecondDigits = 9
837
838 // Split string into seconds and sub-seconds parts.
839- ss, sn, _ := strings.Cut(s, ".")
840+ ss, sn := s, ""
841+ if pos := strings.IndexByte(s, '.'); pos >= 0 {
842+ ss, sn = s[:pos], s[pos+1:]
843+ }
844
845 // Parse the seconds.
846 secs, err := strconv.ParseInt(ss, 10, 64)
847@@ -251,32 +254,48 @@ func formatPAXTime(ts time.Time) (s string) {
848 // return the remainder as r.
849 func parsePAXRecord(s string) (k, v, r string, err error) {
850 // The size field ends at the first space.
851- nStr, rest, ok := strings.Cut(s, " ")
852- if !ok {
853+ sp := strings.IndexByte(s, ' ')
854+ if sp == -1 {
855 return "", "", s, ErrHeader
856 }
857
858 // Parse the first token as a decimal integer.
859- n, perr := strconv.ParseInt(nStr, 10, 0) // Intentionally parse as native int
860- if perr != nil || n < 5 || n > int64(len(s)) {
861+ n, perr := strconv.ParseInt(s[:sp], 10, 0) // Intentionally parse as native int
862+ if perr != nil || n < 5 || int64(len(s)) < n {
863 return "", "", s, ErrHeader
864 }
865- n -= int64(len(nStr) + 1) // convert from index in s to index in rest
866- if n <= 0 {
867+
868+ afterSpace := int64(sp + 1)
869+ beforeLastNewLine := n - 1
870+ // In some cases, "length" was perhaps padded/malformed, and
871+ // trying to index past where the space supposedly is goes past
872+ // the end of the actual record.
873+ // For example:
874+ // "0000000000000000000000000000000030 mtime=1432668921.098285006\n30 ctime=2147483649.15163319"
875+ // ^ ^
876+ // | |
877+ // | afterSpace=35
878+ // |
879+ // beforeLastNewLine=29
880+ // yet indexOf(firstSpace) MUST BE before endOfRecord.
881+ //
882+ // See https://golang.org/issues/40196.
883+ if afterSpace >= beforeLastNewLine {
884 return "", "", s, ErrHeader
885 }
886
887 // Extract everything between the space and the final newline.
888- rec, nl, rem := rest[:n-1], rest[n-1:n], rest[n:]
889+ rec, nl, rem := s[afterSpace:beforeLastNewLine], s[beforeLastNewLine:n], s[n:]
890 if nl != "\n" {
891 return "", "", s, ErrHeader
892 }
893
894 // The first equals separates the key from the value.
895- k, v, ok = strings.Cut(rec, "=")
896- if !ok {
897+ eq := strings.IndexByte(rec, '=')
898+ if eq == -1 {
899 return "", "", s, ErrHeader
900 }
901+ k, v = rec[:eq], rec[eq+1:]
902
903 if !validPAXRecord(k, v) {
904 return "", "", s, ErrHeader
905@@ -315,7 +334,7 @@ func formatPAXRecord(k, v string) (string, error) {
906 // for the PAX version of the USTAR string fields.
907 // The key must not contain an '=' character.
908 func validPAXRecord(k, v string) bool {
909- if k == "" || strings.Contains(k, "=") {
910+ if k == "" || strings.IndexByte(k, '=') >= 0 {
911 return false
912 }
913 switch k {
914diff --git a/vendor/archive/tar/tar_test.go b/vendor/archive/tar/tar_test.go
915index a476f5eb01..e9fafc7cc7 100644
916--- a/vendor/archive/tar/tar_test.go
917+++ b/vendor/archive/tar/tar_test.go
918@@ -23,7 +23,7 @@ import (
919
920 type testError struct{ error }
921
922-type fileOps []any // []T where T is (string | int64)
923+type fileOps []interface{} // []T where T is (string | int64)
924
925 // testFile is an io.ReadWriteSeeker where the IO operations performed
926 // on it must match the list of operations in ops.
927diff --git a/vendor/archive/tar/writer.go b/vendor/archive/tar/writer.go
928index 9b2e3e25d4..893eac00ae 100644
929--- a/vendor/archive/tar/writer.go
930+++ b/vendor/archive/tar/writer.go
931@@ -50,7 +50,7 @@ func (tw *Writer) Flush() error {
932 if tw.err != nil {
933 return tw.err
934 }
935- if nb := tw.curr.logicalRemaining(); nb > 0 {
936+ if nb := tw.curr.LogicalRemaining(); nb > 0 {
937 return fmt.Errorf("archive/tar: missed writing %d bytes", nb)
938 }
939 if _, tw.err = tw.w.Write(zeroBlock[:tw.pad]); tw.err != nil {
940@@ -117,8 +117,8 @@ func (tw *Writer) writeUSTARHeader(hdr *Header) error {
941 // Pack the main header.
942 var f formatter
943 blk := tw.templateV7Plus(hdr, f.formatString, f.formatOctal)
944- f.formatString(blk.toUSTAR().prefix(), namePrefix)
945- blk.setFormat(FormatUSTAR)
946+ f.formatString(blk.USTAR().Prefix(), namePrefix)
947+ blk.SetFormat(FormatUSTAR)
948 if f.err != nil {
949 return f.err // Should never happen since header is validated
950 }
951@@ -211,7 +211,7 @@ func (tw *Writer) writePAXHeader(hdr *Header, paxHdrs map[string]string) error {
952 var f formatter // Ignore errors since they are expected
953 fmtStr := func(b []byte, s string) { f.formatString(b, toASCII(s)) }
954 blk := tw.templateV7Plus(hdr, fmtStr, f.formatOctal)
955- blk.setFormat(FormatPAX)
956+ blk.SetFormat(FormatPAX)
957 if err := tw.writeRawHeader(blk, hdr.Size, hdr.Typeflag); err != nil {
958 return err
959 }
960@@ -253,10 +253,10 @@ func (tw *Writer) writeGNUHeader(hdr *Header) error {
961 var spb []byte
962 blk := tw.templateV7Plus(hdr, f.formatString, f.formatNumeric)
963 if !hdr.AccessTime.IsZero() {
964- f.formatNumeric(blk.toGNU().accessTime(), hdr.AccessTime.Unix())
965+ f.formatNumeric(blk.GNU().AccessTime(), hdr.AccessTime.Unix())
966 }
967 if !hdr.ChangeTime.IsZero() {
968- f.formatNumeric(blk.toGNU().changeTime(), hdr.ChangeTime.Unix())
969+ f.formatNumeric(blk.GNU().ChangeTime(), hdr.ChangeTime.Unix())
970 }
971 // TODO(dsnet): Re-enable this when adding sparse support.
972 // See https://golang.org/issue/22735
973@@ -296,7 +296,7 @@ func (tw *Writer) writeGNUHeader(hdr *Header) error {
974 f.formatNumeric(blk.GNU().RealSize(), realSize)
975 }
976 */
977- blk.setFormat(FormatGNU)
978+ blk.SetFormat(FormatGNU)
979 if err := tw.writeRawHeader(blk, hdr.Size, hdr.Typeflag); err != nil {
980 return err
981 }
982@@ -324,28 +324,28 @@ type (
983 // The block returned is only valid until the next call to
984 // templateV7Plus or writeRawFile.
985 func (tw *Writer) templateV7Plus(hdr *Header, fmtStr stringFormatter, fmtNum numberFormatter) *block {
986- tw.blk.reset()
987+ tw.blk.Reset()
988
989 modTime := hdr.ModTime
990 if modTime.IsZero() {
991 modTime = time.Unix(0, 0)
992 }
993
994- v7 := tw.blk.toV7()
995- v7.typeFlag()[0] = hdr.Typeflag
996- fmtStr(v7.name(), hdr.Name)
997- fmtStr(v7.linkName(), hdr.Linkname)
998- fmtNum(v7.mode(), hdr.Mode)
999- fmtNum(v7.uid(), int64(hdr.Uid))
1000- fmtNum(v7.gid(), int64(hdr.Gid))
1001- fmtNum(v7.size(), hdr.Size)
1002- fmtNum(v7.modTime(), modTime.Unix())
1003+ v7 := tw.blk.V7()
1004+ v7.TypeFlag()[0] = hdr.Typeflag
1005+ fmtStr(v7.Name(), hdr.Name)
1006+ fmtStr(v7.LinkName(), hdr.Linkname)
1007+ fmtNum(v7.Mode(), hdr.Mode)
1008+ fmtNum(v7.UID(), int64(hdr.Uid))
1009+ fmtNum(v7.GID(), int64(hdr.Gid))
1010+ fmtNum(v7.Size(), hdr.Size)
1011+ fmtNum(v7.ModTime(), modTime.Unix())
1012
1013- ustar := tw.blk.toUSTAR()
1014- fmtStr(ustar.userName(), hdr.Uname)
1015- fmtStr(ustar.groupName(), hdr.Gname)
1016- fmtNum(ustar.devMajor(), hdr.Devmajor)
1017- fmtNum(ustar.devMinor(), hdr.Devminor)
1018+ ustar := tw.blk.USTAR()
1019+ fmtStr(ustar.UserName(), hdr.Uname)
1020+ fmtStr(ustar.GroupName(), hdr.Gname)
1021+ fmtNum(ustar.DevMajor(), hdr.Devmajor)
1022+ fmtNum(ustar.DevMinor(), hdr.Devminor)
1023
1024 return &tw.blk
1025 }
1026@@ -354,7 +354,7 @@ func (tw *Writer) templateV7Plus(hdr *Header, fmtStr stringFormatter, fmtNum num
1027 // It uses format to encode the header format and will write data as the body.
1028 // It uses default values for all of the other fields (as BSD and GNU tar does).
1029 func (tw *Writer) writeRawFile(name, data string, flag byte, format Format) error {
1030- tw.blk.reset()
1031+ tw.blk.Reset()
1032
1033 // Best effort for the filename.
1034 name = toASCII(name)
1035@@ -364,15 +364,15 @@ func (tw *Writer) writeRawFile(name, data string, flag byte, format Format) erro
1036 name = strings.TrimRight(name, "/")
1037
1038 var f formatter
1039- v7 := tw.blk.toV7()
1040- v7.typeFlag()[0] = flag
1041- f.formatString(v7.name(), name)
1042- f.formatOctal(v7.mode(), 0)
1043- f.formatOctal(v7.uid(), 0)
1044- f.formatOctal(v7.gid(), 0)
1045- f.formatOctal(v7.size(), int64(len(data))) // Must be < 8GiB
1046- f.formatOctal(v7.modTime(), 0)
1047- tw.blk.setFormat(format)
1048+ v7 := tw.blk.V7()
1049+ v7.TypeFlag()[0] = flag
1050+ f.formatString(v7.Name(), name)
1051+ f.formatOctal(v7.Mode(), 0)
1052+ f.formatOctal(v7.UID(), 0)
1053+ f.formatOctal(v7.GID(), 0)
1054+ f.formatOctal(v7.Size(), int64(len(data))) // Must be < 8GiB
1055+ f.formatOctal(v7.ModTime(), 0)
1056+ tw.blk.SetFormat(format)
1057 if f.err != nil {
1058 return f.err // Only occurs if size condition is violated
1059 }
1060@@ -514,13 +514,10 @@ func (fw *regFileWriter) ReadFrom(r io.Reader) (int64, error) {
1061 return io.Copy(struct{ io.Writer }{fw}, r)
1062 }
1063
1064-// logicalRemaining implements fileState.logicalRemaining.
1065-func (fw regFileWriter) logicalRemaining() int64 {
1066+func (fw regFileWriter) LogicalRemaining() int64 {
1067 return fw.nb
1068 }
1069-
1070-// logicalRemaining implements fileState.physicalRemaining.
1071-func (fw regFileWriter) physicalRemaining() int64 {
1072+func (fw regFileWriter) PhysicalRemaining() int64 {
1073 return fw.nb
1074 }
1075
1076@@ -532,9 +529,9 @@ type sparseFileWriter struct {
1077 }
1078
1079 func (sw *sparseFileWriter) Write(b []byte) (n int, err error) {
1080- overwrite := int64(len(b)) > sw.logicalRemaining()
1081+ overwrite := int64(len(b)) > sw.LogicalRemaining()
1082 if overwrite {
1083- b = b[:sw.logicalRemaining()]
1084+ b = b[:sw.LogicalRemaining()]
1085 }
1086
1087 b0 := b
1088@@ -562,7 +559,7 @@ func (sw *sparseFileWriter) Write(b []byte) (n int, err error) {
1089 return n, errMissData // Not possible; implies bug in validation logic
1090 case err != nil:
1091 return n, err
1092- case sw.logicalRemaining() == 0 && sw.physicalRemaining() > 0:
1093+ case sw.LogicalRemaining() == 0 && sw.PhysicalRemaining() > 0:
1094 return n, errUnrefData // Not possible; implies bug in validation logic
1095 case overwrite:
1096 return n, ErrWriteTooLong
1097@@ -584,12 +581,12 @@ func (sw *sparseFileWriter) ReadFrom(r io.Reader) (n int64, err error) {
1098
1099 var readLastByte bool
1100 pos0 := sw.pos
1101- for sw.logicalRemaining() > 0 && !readLastByte && err == nil {
1102+ for sw.LogicalRemaining() > 0 && !readLastByte && err == nil {
1103 var nf int64 // Size of fragment
1104 dataStart, dataEnd := sw.sp[0].Offset, sw.sp[0].endOffset()
1105 if sw.pos < dataStart { // In a hole fragment
1106 nf = dataStart - sw.pos
1107- if sw.physicalRemaining() == 0 {
1108+ if sw.PhysicalRemaining() == 0 {
1109 readLastByte = true
1110 nf--
1111 }
1112@@ -619,18 +616,18 @@ func (sw *sparseFileWriter) ReadFrom(r io.Reader) (n int64, err error) {
1113 return n, errMissData // Not possible; implies bug in validation logic
1114 case err != nil:
1115 return n, err
1116- case sw.logicalRemaining() == 0 && sw.physicalRemaining() > 0:
1117+ case sw.LogicalRemaining() == 0 && sw.PhysicalRemaining() > 0:
1118 return n, errUnrefData // Not possible; implies bug in validation logic
1119 default:
1120 return n, ensureEOF(rs)
1121 }
1122 }
1123
1124-func (sw sparseFileWriter) logicalRemaining() int64 {
1125+func (sw sparseFileWriter) LogicalRemaining() int64 {
1126 return sw.sp[len(sw.sp)-1].endOffset() - sw.pos
1127 }
1128-func (sw sparseFileWriter) physicalRemaining() int64 {
1129- return sw.fw.physicalRemaining()
1130+func (sw sparseFileWriter) PhysicalRemaining() int64 {
1131+ return sw.fw.PhysicalRemaining()
1132 }
1133
1134 // zeroWriter may only be written with NULs, otherwise it returns errWriteHole.
1135diff --git a/vendor/archive/tar/writer_test.go b/vendor/archive/tar/writer_test.go
1136index 640264984a..4e709e5cac 100644
1137--- a/vendor/archive/tar/writer_test.go
1138+++ b/vendor/archive/tar/writer_test.go
1139@@ -67,7 +67,7 @@ func TestWriter(t *testing.T) {
1140 testClose struct { // Close() == wantErr
1141 wantErr error
1142 }
1143- testFnc any // testHeader | testWrite | testReadFrom | testClose
1144+ testFnc interface{} // testHeader | testWrite | testReadFrom | testClose
1145 )
1146
1147 vectors := []struct {
1148@@ -987,9 +987,11 @@ func TestIssue12594(t *testing.T) {
1149 // The prefix field should never appear in the GNU format.
1150 var blk block
1151 copy(blk[:], b.Bytes())
1152- prefix := string(blk.toUSTAR().prefix())
1153- prefix, _, _ = strings.Cut(prefix, "\x00") // Truncate at the NUL terminator
1154- if blk.getFormat() == FormatGNU && len(prefix) > 0 && strings.HasPrefix(name, prefix) {
1155+ prefix := string(blk.USTAR().Prefix())
1156+ if i := strings.IndexByte(prefix, 0); i >= 0 {
1157+ prefix = prefix[:i] // Truncate at the NUL terminator
1158+ }
1159+ if blk.GetFormat() == FormatGNU && len(prefix) > 0 && strings.HasPrefix(name, prefix) {
1160 t.Errorf("test %d, found prefix in GNU format: %s", i, prefix)
1161 }
1162
1163@@ -1054,11 +1056,11 @@ func TestFileWriter(t *testing.T) {
1164 wantCnt int64
1165 wantErr error
1166 }
1167- testRemaining struct { // logicalRemaining() == wantLCnt, physicalRemaining() == wantPCnt
1168+ testRemaining struct { // LogicalRemaining() == wantLCnt, PhysicalRemaining() == wantPCnt
1169 wantLCnt int64
1170 wantPCnt int64
1171 }
1172- testFnc any // testWrite | testReadFrom | testRemaining
1173+ testFnc interface{} // testWrite | testReadFrom | testRemaining
1174 )
1175
1176 type (
1177@@ -1071,7 +1073,7 @@ func TestFileWriter(t *testing.T) {
1178 sph sparseHoles
1179 size int64
1180 }
1181- fileMaker any // makeReg | makeSparse
1182+ fileMaker interface{} // makeReg | makeSparse
1183 )
1184
1185 vectors := []struct {
1186@@ -1317,11 +1319,11 @@ func TestFileWriter(t *testing.T) {
1187 t.Errorf("test %d.%d, expected %d more operations", i, j, len(f.ops))
1188 }
1189 case testRemaining:
1190- if got := fw.logicalRemaining(); got != tf.wantLCnt {
1191- t.Errorf("test %d.%d, logicalRemaining() = %d, want %d", i, j, got, tf.wantLCnt)
1192+ if got := fw.LogicalRemaining(); got != tf.wantLCnt {
1193+ t.Errorf("test %d.%d, LogicalRemaining() = %d, want %d", i, j, got, tf.wantLCnt)
1194 }
1195- if got := fw.physicalRemaining(); got != tf.wantPCnt {
1196- t.Errorf("test %d.%d, physicalRemaining() = %d, want %d", i, j, got, tf.wantPCnt)
1197+ if got := fw.PhysicalRemaining(); got != tf.wantPCnt {
1198+ t.Errorf("test %d.%d, PhysicalRemaining() = %d, want %d", i, j, got, tf.wantPCnt)
1199 }
1200 default:
1201 t.Fatalf("test %d.%d, unknown test operation: %T", i, j, tf)