RFC 1950 section 2.2 "Data format" says "CINFO (Compression info)... For
CM = 8... Values of CINFO above 7 are not allowed".
Change-Id: Ibbc1213125c7dc045f09901ee7746660e90b5fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/395734
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Nigel Tao <nigeltao@golang.org>
"io"
)
-const zlibDeflate = 8
+const (
+ zlibDeflate = 8
+ zlibMaxWindow = 7
+)
var (
// ErrChecksum is returned when reading ZLIB data that has an invalid checksum.
return z.err
}
h := uint(z.scratch[0])<<8 | uint(z.scratch[1])
- if (z.scratch[0]&0x0f != zlibDeflate) || (h%31 != 0) {
+ if (z.scratch[0]&0x0f != zlibDeflate) || (z.scratch[0]>>4 > zlibMaxWindow) || (h%31 != 0) {
z.err = ErrHeader
return z.err
}
nil,
},
{
- "bad header",
+ "bad header (CINFO)",
+ "",
+ []byte{0x88, 0x98, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01},
+ nil,
+ ErrHeader,
+ },
+ {
+ "bad header (FCHECK)",
"",
[]byte{0x78, 0x9f, 0x03, 0x00, 0x00, 0x00, 0x00, 0x01},
nil,