Skip to content

Commit

Permalink
Protect against corrupted bitstream
Browse files Browse the repository at this point in the history
  • Loading branch information
flanglet committed Jul 16, 2024
1 parent f484742 commit 978886f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions v2/entropy/ANSRangeCodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -874,11 +874,11 @@ func (this *ANSRangeDecoder) decodeChunkV2(block []byte) bool {
st2 := int(this.bitstream.ReadBits(32))
st3 := int(this.bitstream.ReadBits(32))

if sz == 0 {
return len(block) == 0
if len(block) == 0 {
return true
}

minBufSize := max(int(sz+(sz>>3)), len(block))
minBufSize := max(2*len(block), 256) // protect against corrupted bitstream

// Add some padding
if len(this.buffer) < minBufSize {
Expand Down

0 comments on commit 978886f

Please sign in to comment.