Skip to content

Commit

Permalink
zstd: Reject empty compressed blocks (#862)
Browse files Browse the repository at this point in the history
* zstd: Reject empty compressed blocks
* Update good inputs

Matches zstandard behaviour.
  • Loading branch information
klauspost authored Sep 18, 2023
1 parent 7b22298 commit 6125c11
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions zstd/blockdec.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,9 @@ func (b *blockDec) decodeCompressed(hist *history) error {
return err
}
if hist.decoders.nSeqs == 0 {
if len(hist.decoders.literals) == 0 {
return errors.New("invalid block: no literals nor sequences found")
}
b.dst = append(b.dst, hist.decoders.literals...)
return nil
}
Expand Down
Binary file modified zstd/testdata/good.zip
Binary file not shown.

0 comments on commit 6125c11

Please sign in to comment.