Skip to content

Commit

Permalink
fse: Fix max header size (#881)
Browse files Browse the repository at this point in the history
In rare cases the FSE may be calculated too small.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64014

Replace fuzz corpus with one with better base coverage.
  • Loading branch information
klauspost authored Nov 9, 2023
1 parent dc4151f commit 847c1b4
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fse/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func (s *Scratch) writeCount() error {
previous0 bool
charnum uint16

maxHeaderSize = ((int(s.symbolLen) * int(tableLog)) >> 3) + 3
maxHeaderSize = ((int(s.symbolLen)*int(tableLog) + 4 + 2) >> 3) + 3

// Write Table Size
bitStream = uint32(tableLog - minTablelog)
Expand Down
2 changes: 1 addition & 1 deletion fse/fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

func FuzzCompress(f *testing.F) {
fuzz.AddFromZip(f, "testdata/fse_compress.zip", fuzz.TypeRaw, false)
fuzz.AddFromZip(f, "testdata/fse_compress.zip", fuzz.TypeGoFuzz, false)
f.Fuzz(func(t *testing.T, buf0 []byte) {
var s, s2 Scratch
b, err := Compress(buf0, &s)
Expand Down
Binary file modified fse/testdata/fse_compress.zip
Binary file not shown.

0 comments on commit 847c1b4

Please sign in to comment.