Skip to content

Commit

Permalink
zstd: Revert "Disallow 0 sized compressed blocks" (#527)
Browse files Browse the repository at this point in the history
Fixes #526

Bonus, use `ignorecrc` for disabling crc checks in while fuzzing.
  • Loading branch information
klauspost committed Mar 11, 2022
1 parent 2d315d3 commit 7c7079e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions zstd/blockdec.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,9 @@ func (b *blockDec) reset(br byteBuffer, windowSize uint64) error {
}
return ErrCompressedSizeTooBig
}
// Empty compressed blocks not valid in practice,
// see https://github.com/facebook/zstd/issues/3090
if cSize < 3 {
// Empty compressed blocks must at least be 2 bytes
// for Literals_Block_Type and one for Sequences_Section_Header.
if cSize < 2 {
return ErrBlockTooSmall
}
case blockTypeRaw:
Expand Down
4 changes: 2 additions & 2 deletions zstd/fuzz.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build gofuzz
// +build gofuzz
//go:build ignorecrc
// +build ignorecrc

// Copyright 2019+ Klaus Post. All rights reserved.
// License information can be found in the LICENSE file.
Expand Down
4 changes: 2 additions & 2 deletions zstd/fuzz_none.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !gofuzz
// +build !gofuzz
//go:build !ignorecrc
// +build !ignorecrc

// Copyright 2019+ Klaus Post. All rights reserved.
// License information can be found in the LICENSE file.
Expand Down
Binary file modified zstd/testdata/bad.zip
Binary file not shown.
Binary file modified zstd/testdata/good.zip
Binary file not shown.

0 comments on commit 7c7079e

Please sign in to comment.