1
1
mirror of https://github.com/wader/fq.git synced 2024-11-27 06:04:47 +03:00

gzip: fuzz: Don't uncompress on unknown compress method (nil create reader fn)

This commit is contained in:
Mattias Wadman 2021-12-06 15:41:39 +01:00
parent 91cc6d80f7
commit 3601fe3bcb

View File

@ -106,16 +106,18 @@ func gzDecode(d *decode.D, in interface{}) interface{} {
rFn = func(r io.Reader) io.Reader { return flate.NewReader(r) } rFn = func(r io.Reader) io.Reader { return flate.NewReader(r) }
} }
readCompressedSize, uncompressedBB, dv, _, _ := d.TryFieldReaderRangeFormat("uncompressed", d.Pos(), d.BitsLeft(), rFn, probeFormat, nil) if rFn != nil {
if uncompressedBB != nil { readCompressedSize, uncompressedBB, dv, _, _ := d.TryFieldReaderRangeFormat("uncompressed", d.Pos(), d.BitsLeft(), rFn, probeFormat, nil)
if dv == nil { if uncompressedBB != nil {
d.FieldRootBitBuf("uncompressed", uncompressedBB) if dv == nil {
d.FieldRootBitBuf("uncompressed", uncompressedBB)
}
d.FieldRawLen("compressed", readCompressedSize)
crc32W := crc32.NewIEEE()
d.MustCopy(crc32W, uncompressedBB.Clone())
d.FieldU32("crc32", d.ValidateUBytes(crc32W.Sum(nil)), scalar.Hex)
d.FieldU32("isize")
} }
d.FieldRawLen("compressed", readCompressedSize)
crc32W := crc32.NewIEEE()
d.MustCopy(crc32W, uncompressedBB.Clone())
d.FieldU32("crc32", d.ValidateUBytes(crc32W.Sum(nil)), scalar.Hex)
d.FieldU32("isize")
} }
return nil return nil