aboutsummaryrefslogtreecommitdiff
path: root/src/archive
AgeCommit message (Collapse)Author
27 hoursall: prealloc slice with possible minimum capabilitiesShulhan
8 daysarchive/tar: limit the number of old GNU sparse format entriesDamien Neil
We did not set a limit on the maximum size of sparse maps in the old GNU sparse format. Set a limit based on the cumulative size of the extension blocks used to encode the map (consistent with how we limit the sparse map size for other formats). Add an additional limit to the total number of sparse file entries, regardless of encoding, to all sparse formats. Thanks to Colin Walters (walters@verbum.org), Uuganbayar Lkhamsuren (https://github.com/uug4na), and Jakub Ciolek for reporting this issue. Fixes #78301 Fixes CVE-2026-32288 Change-Id: I84877345d7b41cc60c58771860ba70e16a6a6964 Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/3901 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Roland Shoemaker <bracewell@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/763766 Auto-Submit: David Chase <drchase@google.com> TryBot-Bypass: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
2026-01-15archive/zip: reduce CPU usage in index constructionDamien Neil
Constructing the zip index (which is done once when first opening a file in an archive) can consume large amounts of CPU when processing deeply-nested directory paths. Switch to a less inefficient algorithm. Thanks to Jakub Ciolek for reporting this issue. goos: darwin goarch: arm64 pkg: archive/zip cpu: Apple M4 Pro │ /tmp/bench.0 │ /tmp/bench.1 │ │ sec/op │ sec/op vs base │ ReaderOneDeepDir-14 25983.62m ± 2% 46.01m ± 2% -99.82% (p=0.000 n=8) ReaderManyDeepDirs-14 16.221 ± 1% 2.763 ± 6% -82.96% (p=0.000 n=8) ReaderManyShallowFiles-14 130.3m ± 1% 128.8m ± 2% -1.20% (p=0.003 n=8) geomean 3.801 253.9m -93.32% Fixes #77102 Fixes CVE-2025-61728 Change-Id: I2c9c864be01b2a2769eb67fbab1b250aeb8f6c42 Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/3060 Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-by: Neal Patel <nealpatel@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/736713 Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-12-30all: fix some minor grammatical issues in the commentscuishuang
Change-Id: I0459f05e7f6abd9738813c65d993114e931720d5 Reviewed-on: https://go-review.googlesource.com/c/go/+/731000 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org>
2025-12-15archive/tar, compress/bzip2: base64 some troublesome testdata filesIan Lance Taylor
This avoids complaints from scanners that look for and open tar and bz2 files, and complain if they look weird. In this case, they do look weird, because they are intentionally strange. This kind of thing shouldn't be necessary, but we already have the machinery to do it so it's easy enough. Fixes #76799 Change-Id: Ib302b3aef30108a1325f91fcb2d166f8e1863792 Reviewed-on: https://go-review.googlesource.com/c/go/+/729780 Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2025-10-17all: remove unnecessary loop variable copies in testsTobias Klauser
Copying the loop variable is no longer necessary since Go 1.22. Change-Id: Iebb21dac44a20ec200567f1d786f105a4ee4999d Reviewed-on: https://go-review.googlesource.com/c/go/+/711640 Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-10-07archive/tar: set a limit on the size of GNU sparse file 1.0 regionsDamien Neil
Sparse files in tar archives contain only the non-zero components of the file. There are several different encodings for sparse files. When reading GNU tar pax 1.0 sparse files, archive/tar did not set a limit on the size of the sparse region data. A malicious archive containing a large number of sparse blocks could cause archive/tar to read an unbounded amount of data from the archive into memory. Since a malicious input can be highly compressable, a small compressed input could cause very large allocations. Cap the size of the sparse block data to the same limit used for PAX headers (1 MiB). Thanks to Harshit Gupta (Mr HAX) (https://www.linkedin.com/in/iam-harshit-gupta/) for reporting this issue. Fixes CVE-2025-58183 Fixes #75677 Change-Id: I70b907b584a7b8676df8a149a1db728ae681a770 Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/2800 Reviewed-by: Roland Shoemaker <bracewell@google.com> Reviewed-by: Nicholas Husin <husin@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/709861 Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Bypass: Michael Pratt <mpratt@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-09-11archive/tar: fix typo in benchmark nameJoe Tsai
This was accidentally introduced in CL 662835. Change-Id: I5c7ac67337e33e82037414377912b57d2a45be91 Reviewed-on: https://go-review.googlesource.com/c/go/+/702275 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-09-08archive/tar: optimize nanosecond parsing in parsePAXTime1911860538
Modified parsePAXTime to use a byte array for nanosecond parsing, providing a more straightforward implementation with better performance when handling decimal fraction part. Here are benchmark results: goos: darwin goarch: amd64 pkg: archive/tar cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz │ old.txt │ new.txt │ │ sec/op │ sec/op vs base │ ParsePAXTIme/NoNanos-8 20.55n ± 4% 20.45n ± 12% ~ (p=1.000 n=10) ParsePAXTIme/ExactNanos-8 52.42n ± 2% 42.16n ± 3% -19.57% (p=0.000 n=10) ParsePAXTIme/WithNanoPadding-8 99.33n ± 2% 39.58n ± 2% -60.16% (p=0.000 n=10) ParsePAXTIme/WithNanoTruncate-8 54.78n ± 1% 43.64n ± 4% -20.34% (p=0.000 n=10) ParsePAXTIme/TrailingError-8 31.87n ± 4% 17.55n ± 2% -44.94% (p=0.000 n=10) ParsePAXTIme/LeadingError-8 31.03n ± 2% 15.81n ± 6% -49.03% (p=0.000 n=10) Change-Id: If05ef512137d0115db9cb6d3ab432335230628bb GitHub-Last-Rev: 106d25e5cfd57e0264b4510c58d09e8f80e13b3f GitHub-Pull-Request: golang/go#73164 Reviewed-on: https://go-review.googlesource.com/c/go/+/662835 Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-03-11archive/zip: error on ReadDir if there are invalid file namesSean Liao
Fixes #50179 Change-Id: I616a6d1279d025e345d2daa6d44b687c8a2d09e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/656495 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-03-07archive/zip: preallocate fileList size for Reader.OpenOlivier Mengué
When building the index of file entries for Reader.Open (when the Reader is used as an io/fs.FS), reduce reallocations by pre-allocating the count of entries based on the count of file entries. Change-Id: I05048337cb5e752054b3e984a8a5ec5199c4589b Reviewed-on: https://go-review.googlesource.com/c/go/+/655476 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-02-03io/fs: add ReadLinkFS interfaceRoxy Light
Added implementations for *io/fs.subFS, os.DirFS, and testing/fstest.MapFS. Amended testing/fstest.TestFS to check behavior. Addressed TODOs in archive/tar and os.CopyFS around symbolic links. I am deliberately not changing archive/zip in this CL, since it currently does not resolve symlinks as part of its filesystem implementation. I am unsure of the compatibility restrictions on doing so, so figured it would be better to address independently. testing/fstest.MapFS now includes resolution of symlinks, with MapFile.Data storing the symlink data. The behavior change there seemed less intrusive, especially given its intended usage in tests, and it is especially helpful in testing the io/fs function implementations. Fixes #49580 Change-Id: I58ec6915e8cc97341cdbfd9c24c67d1b60139447 Reviewed-on: https://go-review.googlesource.com/c/go/+/385534 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Funda Secgin <fundasecgin33@gmail.com>
2025-01-27archive/zip, archive/tar: writer appends slash to directory namesyincong
Fixes #71235 Change-Id: I62aebb9d421db0e4b57ad5cae25c70f47aa5f8f9 GitHub-Last-Rev: 6e0fba07dd128e20e32a3a6258edf80ee91d4690 GitHub-Pull-Request: golang/go#71239 Reviewed-on: https://go-review.googlesource.com/c/go/+/642375 Reviewed-by: Jonathan Amsterdam <jba@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-10-03archive/tar: use hash/crc32 instead of crypto/md5 for test checksumsqmuntal
Using MD5 for checksums in tests is an overkill, as MD5 is designed for cryptographic purposes. Use hash/crc32 instead, which is designed for detecting random data corruptions, aka checksums. Change-Id: I03b30ed7f38fba2a2e59d06bd4133b495f64a013 Reviewed-on: https://go-review.googlesource.com/c/go/+/617675 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: David Chase <drchase@google.com>
2024-10-02all: use slices.Sorted(maps.Keys(m))Tobias Klauser
Use slices.Sorted(maps.Keys(m)) to get a sorted slices of the keys in a map. Do not change packages built during bootstrap, as the bootstrap compiler (currently 1.22.6) does not have the required maps and slices functions. Change-Id: Ie35565d241fa14aca56b730a69af010127b659ab Reviewed-on: https://go-review.googlesource.com/c/go/+/617356 Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-09-23archive/{zip,tar}: fix Writer.AddFS to include empty directoriesSong Gao
This change modifies the `(*Writer).AddFS` implementation in both `archive/zip` and `archive/tar` to always write a directory header. This fixes a bug where any empty directories in the fs were omitted when a zip or tar archive was created from `AddFS` method. Fixes #66831 Change-Id: Id32c9c747f9f65ec7db4aeefeaffa83567215bfc Reviewed-on: https://go-review.googlesource.com/c/go/+/578415 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-09-13archive/tar: make use of maps.CloneJes Cok
Change-Id: I2a9d849410002dae1f49a53597298c1903954d12 GitHub-Last-Rev: 20a56b4161dd0864f67d427301cb28563f2c3d50 GitHub-Pull-Request: golang/go#69427 Reviewed-on: https://go-review.googlesource.com/c/go/+/612737 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-08-03archive/zip,cmd/compile: simplify the split functionapocelipes
Use strings to simplify the code. This is a follow-up for the CL 586715. Change-Id: I9e5470ec271e8af1ad4ddbb5f01f43a8a4879557 GitHub-Last-Rev: b95d6179781053ea8ec9fc8ad2e18607fd35c5bb GitHub-Pull-Request: golang/go#68713 Reviewed-on: https://go-review.googlesource.com/c/go/+/602697 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-07-25archive: use slices and maps to clean up testsapocelipes
Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is much faster. Clean up some unnecessary helper functions. Change-Id: I9b94bd43886302b9b327539ab065a435ce0d75d9 GitHub-Last-Rev: b9ca21f165bcc5e45733e6a511a2344b1aa4a281 GitHub-Pull-Request: golang/go#67607 Reviewed-on: https://go-review.googlesource.com/c/go/+/587936 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2024-07-16archive/zip: document handling of duplicate names in Writer.CreateSean Liao
Fixes #66810 Change-Id: I6a7848dce245ae14941d61d2f78abaf0dc5c1247 Reviewed-on: https://go-review.googlesource.com/c/go/+/597978 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-05-28archive/zip: fix UncompressedSize godocRTann
Change-Id: I0c142eb18af7b03759041e894bbce0f365ea9d7e Reviewed-on: https://go-review.googlesource.com/c/go/+/588116 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-23all: change from sort functions to slices functions where feasibleIan Lance Taylor
Doing this because the slices functions are slightly faster and slightly easier to use. It also removes one dependency layer. This CL does not change packages that are used during bootstrap, as the bootstrap compiler does not have the required slices functions. It does not change the go/scanner package because the ErrorList Len, Swap, and Less methods are part of the Go 1 API. Change-Id: If52899be791c829198e11d2408727720b91ebe8a Reviewed-on: https://go-review.googlesource.com/c/go/+/587655 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-05-16archive/zip: treat truncated EOCDR comment as an errorDamien Neil
When scanning for an end of central directory record, treat an EOCDR signature with a record containing a truncated comment as an error. Previously, we would skip over the invalid record and look for another one. Other implementations do not do this (they either consider this a hard error, or just ignore the truncated comment). This parser misalignment allowed presenting entirely different archive contents to Go programs and other zip decoders. Fixes #66869 Change-Id: I94e5cb028534bb5704588b8af27f1e22ea49c7c6 Reviewed-on: https://go-review.googlesource.com/c/go/+/585397 Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-04archive/zip: fix a broken URL in a comment in writeDataDescriptorLiam Miller-Cushon
The comment contains a dead link to a OpenJDK bug ID 7073588 this change fixes the link. Change-Id: Ib9b10362c707507e59bb6f340d52a0025f65e292 GitHub-Last-Rev: 37af15b947a59346e23191dad264efa0aaa461af GitHub-Pull-Request: golang/go#66669 Reviewed-on: https://go-review.googlesource.com/c/go/+/576335 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-03-27all: make use of builtin clearJes Cok
Change-Id: I1df0685c75fc1044ba46003a69ecc7dfc53bbc2b Reviewed-on: https://go-review.googlesource.com/c/go/+/574675 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-15archive/tar: add FileInfoNames interfaceqiulaidongfeng
An optional interface FileInfoNames has been added. If the parameter fi of FileInfoHeader implements the interface the Gname/Uname of the return value Header are provided by the method of the interface. Also added testing. Fixes #50102 Change-Id: I47976e238eb20ed43113b060e4f83a14ae49493e GitHub-Last-Rev: a213613c79e150d52a2f5c84dca7a49fe123fa40 GitHub-Pull-Request: golang/go#65273 Reviewed-on: https://go-review.googlesource.com/c/go/+/558355 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-08archive/tar: use built-in clear to simplify codeapocelipes
Change-Id: I0e55dd68d92c39aba511b55368bf50d929d75f86 GitHub-Last-Rev: 17430140783db8bf3354304c8f28d6826186c6cb GitHub-Pull-Request: golang/go#66158 Reviewed-on: https://go-review.googlesource.com/c/go/+/569696 Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-27archive/tar: check returned error before use hdrguoguangwu
Change-Id: I8c28dac73427e37d58d970b00d8f0f1413bede2e GitHub-Last-Rev: a11a8036028ecf6f811b1470becc924b77a2c734 GitHub-Pull-Request: golang/go#65932 Reviewed-on: https://go-review.googlesource.com/c/go/+/566695 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-06archive/zip: reduce memory held by Writer.CopyJonathan Amsterdam
Make a copy of the argument File's FileHeader, and pass a pointer to the copy to CreateRaw. Passing the pointer directly causes the entire `File` to be referenced by the receiver. The `File` includes a reference to the `ReaderAt` underlying the `Reader`, so all its memory, which may be the entire contents of the archive, is prevented from being garbage-collected. Also, explain the issue in the doc comment for CreateRaw. We cannot change its behavior because someone may depend on the preserving the identity of its argument pointer. For #65499. Change-Id: Ieb4963a0ea30539d597547d3511accbd8c6b5c5a Reviewed-on: https://go-review.googlesource.com/c/go/+/560238 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com>
2024-01-24Revert "archive/tar: add FileInfoNames interface"Cherry Mui
This reverts CL 514235. Also reverts CL 518056 which is a followup fix. Reason for revert: Proposal #50102 defined an interface that is too specific to UNIX-y systems and also didn't make much sense. The proposal is un-accepted, and we'll revisit in Go 1.23. Fixes (via backport) #65245. Updates #50102. Change-Id: I41ba0ee286c1d893e6564a337e5d76418d19435d Reviewed-on: https://go-review.googlesource.com/c/go/+/558295 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-10-13archive: add available godoc linkcui fliter
Change-Id: I813aa09f8a65936796469fa637d0f23004d26098 Reviewed-on: https://go-review.googlesource.com/c/go/+/534757 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: shuang cui <imcusg@gmail.com>
2023-09-25all: use the indefinite article an in commentsJes Cok
Change-Id: I8787458f9ccd3b5cdcdda820d8a45deb4f77eade GitHub-Last-Rev: be865d67ef68815b8c1c2a9ad222fff594620e66 GitHub-Pull-Request: golang/go#63165 Reviewed-on: https://go-review.googlesource.com/c/go/+/530120 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2023-09-22all: clean unnecessary casts for test filesJes Cok
This is a follow up of CL 528696. Change-Id: I5b71eabedb12567c4b1b36f7182a3d2b0ed662a5 GitHub-Last-Rev: acaf3ac11c38042ad27b99e1c70a3c9f1a554a15 GitHub-Pull-Request: golang/go#62713 Reviewed-on: https://go-review.googlesource.com/c/go/+/529197 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-18all: clean unnecessary castsJes Cok
Run 'unconvert -safe -apply' (https://github.com/mdempsky/unconvert) Change-Id: I24b7cd7d286cddce86431d8470d15c5f3f0d1106 GitHub-Last-Rev: 022e75384c08bb899a8951ba0daffa0f2e14d5a7 GitHub-Pull-Request: golang/go#62662 Reviewed-on: https://go-review.googlesource.com/c/go/+/528696 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2023-09-15archive/zip: reject non-regular files in AddFSMauri de Souza Meneguzzo
When a filesystem with non-regular files is used the resulting files inside the zip archive are empty. In this case we can be explicit and return an error. Fixes #61875 Change-Id: I1aeac544521002e0c4bad328e73f51852ad4eee3 GitHub-Last-Rev: 5e53dcfd7c12e45d4142016d0b9b286f9aa83d56 GitHub-Pull-Request: golang/go#61876 Reviewed-on: https://go-review.googlesource.com/c/go/+/517475 Auto-Submit: Ian Lance Taylor <iant@golang.org> Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: David Chase <drchase@google.com>
2023-09-13archive/tar: add AddFS method to WriterMauri de Souza Meneguzzo
The method AddFS can be used to add the contents of a fs.FS filesystem to a tar archive. This method walks the directory tree starting at the root of the filesystem and adds each file to the archive. Fixes #58000 Change-Id: I0e6abac76b76bc5d95b74b7e5b37634ce3f76c85 GitHub-Last-Rev: 11a62bfd7ebc7ca93b1832da15018e6805c92520 GitHub-Pull-Request: golang/go#61599 Reviewed-on: https://go-review.googlesource.com/c/go/+/513316 Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-09-12all: fix Microsoft linksqmuntal
This CL fixes the links to Microsoft documentation in the Go source code. Some links were broken and some others were outdated. Change-Id: I4c3bcd3aa3c07a31be1b7f94c25339dcc2e771e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/527556 Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Quim Muntal <quimmuntal@gmail.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2023-08-30archive/zip: update link to zip specificationYusuf Birader
Change-Id: Iad902ec2a13b0c5c594c60ecac0b40f641574a1e Reviewed-on: https://go-review.googlesource.com/c/go/+/524275 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-08-10archive/tar: correct value passed to Uname methodIan Lance Taylor
For #50102 Change-Id: I28b5579611b07952b6379bc4603daf29a86a3be0 Reviewed-on: https://go-review.googlesource.com/c/go/+/518056 Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Joseph Tsai <joetsai@digital-static.net> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Tianon Gravi (Andrew) <admwiggin@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: qiulaidongfeng <2645477756@qq.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
2023-08-07archive/tar: add FileInfoNames interfaceqiulaidongfeng
An optional interface FileInfoNames has been added. If the parameter fi of FileInfoHeader implements the interface the Gname and Uname of the return value Header are provided by the method of the interface. Also added testing. Fixes #50102 Change-Id: I6fd06c7c9aaf29b22b7384542fe57affed33009a Change-Id: I6fd06c7c9aaf29b22b7384542fe57affed33009a GitHub-Last-Rev: 5e82257948759e13880d8af12743b9524ae3df5a GitHub-Pull-Request: golang/go#61662 Reviewed-on: https://go-review.googlesource.com/c/go/+/514235 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-08-03archive: use predeclared function minqiulaidongfeng
Change-Id: I23e0005071fcbafeaecaa05f51712dd1de6eed01 Change-Id: I23e0005071fcbafeaecaa05f51712dd1de6eed01 GitHub-Last-Rev: 364d7c74fef1668930b730b05a7539f7ac43e60a GitHub-Pull-Request: golang/go#61661 Reviewed-on: https://go-review.googlesource.com/c/go/+/514215 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-08-01archive/tar: narrow trim range for formatter'formatStringJes Cok
Trim s[:len(b)-1] rather than s[:len(b)], since s[len(b)-1] is '/'. Change-Id: I055da555810c112774549bd13d4faa8bfa0a60dc GitHub-Last-Rev: 457977514d75a6c72086c2f4d89fb601280b8b90 GitHub-Pull-Request: golang/go#60729 Reviewed-on: https://go-review.googlesource.com/c/go/+/502376 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
2023-07-31archive/zip: add AddFS method to zip WriterMauri de Souza Meneguzzo
The method AddFS can be used to add the contents of a fs.FS filesystem to a zip archive. This method walks the directory tree starting at the root of the filesystem and adds each file to the archive. Fixes #54898 Change-Id: I80511cbd91a1d7e09ee52d2d1b09fb5eed25f45f GitHub-Last-Rev: 1e17f2e6bae60cf5168d687dd1357ab58a883675 GitHub-Pull-Request: golang/go#61602 Reviewed-on: https://go-review.googlesource.com/c/go/+/513438 Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-05-24compress/flate, archive/zip: reduce memory allocationsMaksim Meshkov
The existing implementation allocates a new 4KB buffer each time it opens flate-encoded file in a zip archive. This commit allows the flate reader to reuse the buffer on call Reset instead of allocating a new one. It is noticeable when a zip archive contains a huge amount of files, e.g. zip archive has 50_000 files, for each file 4KB buffer is allocated, so it is 200MB memory allocations. If files are read sequentially only one buffer is needed. Fixes #59774 Change-Id: Ib16336b101ba58e8f0f30a45dc5fd4eeebc801a1 GitHub-Last-Rev: f3f395b2ad95b7ad7ce9df6f5e49c7b6a0627627 GitHub-Pull-Request: golang/go#59775 Reviewed-on: https://go-review.googlesource.com/c/go/+/487675 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-05-04all: add String for fs.{FileInfo,DirEntry} implementationsIan Lance Taylor
The new String methods use the new FormatFileInfo and FormatDirEntry functions. Fixes #54451 Change-Id: I414cdfc212ec3c316fb2734756d2117842a23631 Reviewed-on: https://go-review.googlesource.com/c/go/+/491175 Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-04-24archive/zip: reject overflowing directorySize & directoryOffsetRoland Shoemaker
We added a check for incorrect baseOffset in CL 408734, but in doing so we introduced a panic when directoryOffset overflowed a int64. The zip spec uses uint64, but since io.SectionReader requires int64 we convert, and possibly introduce an overflow. If offset < 0 && size-offset < 0, SectionReader will panic when we attempt to read from it. Since it's extremely unlikely we're ever going to process a zip file larger than 1<<63-1 byte, just limit directory size and offset to the max int64. Change-Id: I1aaa755cf4da927a6e12ef59f97dfc83a3426d86 Reviewed-on: https://go-review.googlesource.com/c/go/+/488195 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Roland Shoemaker <roland@golang.org>
2023-04-05archive/zip: return ErrInsecurePath for unsafe paths by OpenReaderImre Rad
zip.NewReader was recently improved to return ErrInsecurePath when insecure entries are encountered. This change adopts the same logic for the OpenReader interface as well. Fixes #58641 Change-Id: I0d8be94d073cc14cf93a914dc250f85b19cec4ab GitHub-Last-Rev: 68391dc51562aebc893ec70fdfbdfb181955983a GitHub-Pull-Request: golang/go#58658 Reviewed-on: https://go-review.googlesource.com/c/go/+/470735 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Damien Neil <dneil@google.com>
2023-04-04all: fix misuses of "a" vs "an"cui fliter
Fixes the misuse of "a" vs "an", according to English grammatical expectations and using https://www.a-or-an.com/ Change-Id: I53ac724070e3ff3d33c304483fe72c023c7cda47 Reviewed-on: https://go-review.googlesource.com/c/go/+/480536 Run-TryBot: shuang cui <imcusg@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-03-02archive/zip: make receiver names consistentOleksandr Redko
Fixes revive linter receiver-naming warnings: - receiver name f should be consistent with previous receiver name e for fileListEntry - receiver name r should be consistent with previous receiver name z for Reader - receiver name f should be consistent with previous receiver name h for FileHeader Change-Id: Ibfa14b97f6ca7adc86e3a1df919c5bb5de9716dc GitHub-Last-Rev: dd7315b09d224bb2953b82cc6bd97d81c9eaca0a GitHub-Pull-Request: golang/go#58477 Reviewed-on: https://go-review.googlesource.com/c/go/+/467519 Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Bypass: Ian Lance Taylor <iant@google.com>
2023-01-20archive/zip: use base offset 0 if it has a valid entryIan Lance Taylor
In CL 408734 we introduced a fall back to base offset 0 if reading a directory entry at the computed base offset failed. We have now found a file in the wild for which the computed base offset is incorrect, but happens to refer to a valid directory entry. In this CL, we change the fallback such that if the first directory header relative to base offset 0 is valid, we just use base offset 0. Change-Id: Ia9ace20c1065d1f651035f16f7d91d741ab1dbf4 Reviewed-on: https://go-review.googlesource.com/c/go/+/461598 Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>