Unverified Commit b13e9c4e authored by Martin Holst Swende's avatar Martin Holst Swende Committed by GitHub

tests/fuzzers: fix false positive in bitutil fuzzer (#22076)

parent 9c6b5b90
...@@ -51,7 +51,19 @@ func fuzzDecode(data []byte) int { ...@@ -51,7 +51,19 @@ func fuzzDecode(data []byte) int {
if err != nil { if err != nil {
return 0 return 0
} }
if comp := bitutil.CompressBytes(blob); !bytes.Equal(comp, data) { // re-compress it (it's OK if the re-compressed differs from the
// original - the first input may not have been compressed at all)
comp := bitutil.CompressBytes(blob)
if len(comp) > len(blob) {
// After compression, it must be smaller or equal
panic("bad compression")
}
// But decompressing it once again should work
decomp, err := bitutil.DecompressBytes(data, 1024)
if err != nil {
panic(err)
}
if !bytes.Equal(decomp, blob) {
panic("content mismatch") panic("content mismatch")
} }
return 1 return 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment