diff options
author | Russ Cox <rsc@golang.org> | 2022-11-28 13:59:49 -0500 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2023-01-19 22:26:43 +0000 |
commit | 213495a4a67c318a1fab6e76093e6690c2141c0e (patch) | |
tree | d0b1256e72ff7256143377d1f17f64f5e5e0c2a6 /src/archive | |
parent | aa51c40b1cc62d53603d7b7aea3232969aa40afe (diff) | |
download | go-213495a4a67c318a1fab6e76093e6690c2141c0e.tar.gz go-213495a4a67c318a1fab6e76093e6690c2141c0e.zip |
internal/godebug: export non-default-behavior counters in runtime/metrics
Allow GODEBUG users to report how many times a setting
resulted in non-default behavior.
Record non-default-behaviors for all existing GODEBUGs.
Also rework tests to ensure that runtime is in sync with runtime/metrics.All,
and generate docs mechanically from metrics.All.
For #56986.
Change-Id: Iefa1213e2a5c3f19ea16cd53298c487952ef05a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/453618
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/archive')
-rw-r--r-- | src/archive/tar/reader.go | 7 | ||||
-rw-r--r-- | src/archive/zip/reader.go | 7 |
2 files changed, 9 insertions, 5 deletions
diff --git a/src/archive/tar/reader.go b/src/archive/tar/reader.go index 768ca1968d..cfa50446ed 100644 --- a/src/archive/tar/reader.go +++ b/src/archive/tar/reader.go @@ -57,8 +57,11 @@ func (tr *Reader) Next() (*Header, error) { } hdr, err := tr.next() tr.err = err - if err == nil && tarinsecurepath.Value() == "0" && !filepath.IsLocal(hdr.Name) { - err = ErrInsecurePath + if err == nil && !filepath.IsLocal(hdr.Name) { + if tarinsecurepath.Value() == "0" { + tarinsecurepath.IncNonDefault() + err = ErrInsecurePath + } } return hdr, err } diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go index a1554d2c52..c29837836b 100644 --- a/src/archive/zip/reader.go +++ b/src/archive/zip/reader.go @@ -108,12 +108,13 @@ func NewReader(r io.ReaderAt, size int64) (*Reader, error) { // Zip permits an empty file name field. continue } - if zipinsecurepath.Value() != "0" { - continue - } // The zip specification states that names must use forward slashes, // so consider any backslashes in the name insecure. if !filepath.IsLocal(f.Name) || strings.Contains(f.Name, `\`) { + if zipinsecurepath.Value() != "0" { + continue + } + zipinsecurepath.IncNonDefault() return zr, ErrInsecurePath } } |