diff options
| author | aimuz <mr.imuz@gmail.com> | 2023-11-15 15:21:23 +0000 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2023-11-17 16:39:21 +0000 |
| commit | ae9fdbd8bca0ec01e522ddb5bc2baf7e27553f67 (patch) | |
| tree | d8e9aa395dcc60a6cd0cddedf1957c5884166f4e /src/internal/zstd/zstd_test.go | |
| parent | 2184a76fb8e1aeb0eb2d5401828548a25f90beae (diff) | |
| download | go-ae9fdbd8bca0ec01e522ddb5bc2baf7e27553f67.tar.xz | |
internal/zstd: fix seek offset bounds check in skipFrame
This change enhances the zstd Reader's skipFrame function to validate
the new offset when skipping frames in a seekable stream, preventing
invalid offsets that could occur previously.
A set of "bad" test strings has been added to fuzz_test.go to extend
the robustness checks against potential decompression panics.
Additionally, a new test named TestReaderBad is introduced in
zstd_test.go to verify proper error handling with corrupted input
strings.
The BenchmarkLarge function has also been refactored for clarity,
removing unnecessary timer stops and resets.
Updates #63824
Change-Id: Iccd248756ad6348afa1395c7799350d07402868a
GitHub-Last-Rev: 63055b91e9413491fe8039ea42d55b823c89ec15
GitHub-Pull-Request: golang/go#64056
Reviewed-on: https://go-review.googlesource.com/c/go/+/541220
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Klaus Post <klauspost@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal/zstd/zstd_test.go')
| -rw-r--r-- | src/internal/zstd/zstd_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/internal/zstd/zstd_test.go b/src/internal/zstd/zstd_test.go index 4ae6f2b398..f2a2e1b585 100644 --- a/src/internal/zstd/zstd_test.go +++ b/src/internal/zstd/zstd_test.go @@ -304,6 +304,17 @@ func TestFileSamples(t *testing.T) { } } +func TestReaderBad(t *testing.T) { + for i, s := range badStrings { + t.Run(fmt.Sprintf("badStrings#%d", i), func(t *testing.T) { + _, err := io.Copy(io.Discard, NewReader(strings.NewReader(s))) + if err == nil { + t.Error("expected error") + } + }) + } +} + func BenchmarkLarge(b *testing.B) { b.StopTimer() b.ReportAllocs() |
