Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compress/gzip: Reader incorrectly performs FHCRC check #15070

Closed
dsnet opened this issue Apr 2, 2016 · 1 comment
Closed

compress/gzip: Reader incorrectly performs FHCRC check #15070

dsnet opened this issue Apr 2, 2016 · 1 comment
Milestone

Comments

@dsnet
Copy link
Member

dsnet commented Apr 2, 2016

Using go1.6

Example code:

b, _ := hex.DecodeString("" +
    "1f8b081200096e8800ff48656c6c6f00" + // GZIP header
    "99d6" + // header.FHCRC (should cover entire header)
    "010000ffff0000000000000000", // GZIP data
)

r, err := gzip.NewReader(bytes.NewReader(b))
if err != nil {
    panic(err)
}
_ = r

This currently errors with gzip.ErrHeader, but should in fact create a gzip.Reader without issue.

Currently, Go only performs the CRC over the first 10 bytes of the header. However, RFC 1952, section 3.2.3 says:

If FHCRC is set, a CRC16 for the gzip header is present, immediately before the compressed data. The CRC16 consists of the two least significant bytes of the CRC32 for all bytes of the gzip header up to and not including the CRC16.

Instead, we should compute the CRC over the whole header.

@dsnet dsnet changed the title compress/gzip: Reader incorrect performs FHCRC check compress/gzip: Reader incorrectly performs FHCRC check Apr 2, 2016
@bradfitz bradfitz added this to the Go1.7 milestone Apr 2, 2016
@gopherbot
Copy link

CL https://golang.org/cl/21466 mentions this issue.

@golang golang locked and limited conversation to collaborators Apr 15, 2017
@rsc rsc unassigned dsnet Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants