diff --git a/zstd/decoder.go b/zstd/decoder.go index b04e36f2ff..4f2d09548c 100644 --- a/zstd/decoder.go +++ b/zstd/decoder.go @@ -451,7 +451,7 @@ func (d *Decoder) nextBlock(blocking bool) (ok bool) { got := d.current.crc.Sum64() var tmp [4]byte binary.LittleEndian.PutUint32(tmp[:], uint32(got)) - if !d.o.ignoreChecksum && !bytes.Equal(tmp[:], next.d.checkCRC) && !ignoreCRC { + if !d.o.ignoreChecksum && !bytes.Equal(tmp[:], next.d.checkCRC) { if debugDecoder { println("CRC Check Failed:", tmp[:], " (got) !=", next.d.checkCRC, "(on stream)") } @@ -534,13 +534,17 @@ func (d *Decoder) nextBlockSync() (ok bool) { } // Update/Check CRC - if !d.o.ignoreChecksum && d.frame.HasCheckSum { - d.frame.crc.Write(d.current.b) - if d.current.d.Last { - d.current.err = d.frame.checkCRC() - if d.current.err != nil { - println("CRC error:", d.current.err) - return false + if d.frame.HasCheckSum { + if !d.o.ignoreChecksum { + d.frame.consumeCRC() + } else { + d.frame.crc.Write(d.current.b) + if d.current.d.Last { + d.current.err = d.frame.checkCRC() + if d.current.err != nil { + println("CRC error:", d.current.err) + return false + } } } } diff --git a/zstd/framedec.go b/zstd/framedec.go index 4b15b2acc9..3ff109cce4 100644 --- a/zstd/framedec.go +++ b/zstd/framedec.go @@ -310,7 +310,7 @@ func (d *frameDec) checkCRC() error { tmp[2] = byte(got >> 16) tmp[3] = byte(got >> 24) - if !bytes.Equal(tmp[:], want) && !ignoreCRC { + if !bytes.Equal(tmp[:], want) { if debugDecoder { println("CRC Check Failed:", tmp[:], "!=", want) } diff --git a/zstd/fuzz.go b/zstd/fuzz.go deleted file mode 100644 index 7f2210e053..0000000000 --- a/zstd/fuzz.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build ignorecrc -// +build ignorecrc - -// Copyright 2019+ Klaus Post. All rights reserved. -// License information can be found in the LICENSE file. -// Based on work by Yann Collet, released under BSD License. - -package zstd - -// ignoreCRC can be used for fuzz testing to ignore CRC values... -const ignoreCRC = true diff --git a/zstd/fuzz_none.go b/zstd/fuzz_none.go deleted file mode 100644 index 6811c68a89..0000000000 --- a/zstd/fuzz_none.go +++ /dev/null @@ -1,11 +0,0 @@ -//go:build !ignorecrc -// +build !ignorecrc - -// Copyright 2019+ Klaus Post. All rights reserved. -// License information can be found in the LICENSE file. -// Based on work by Yann Collet, released under BSD License. - -package zstd - -// ignoreCRC can be used for fuzz testing to ignore CRC values... -const ignoreCRC = false