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 fails to reset Header #15077

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

compress/gzip: Reader fails to reset Header #15077

dsnet opened this issue Apr 2, 2016 · 1 comment

Comments

@dsnet
Copy link
Member

dsnet commented Apr 2, 2016

Using go1.6

Example code:

    var b1, b2 bytes.Buffer
    w1 := gzip.NewWriter(&b1)
    w1.Header.Comment = "Hello"
    w1.Close()

    w2 := gzip.NewWriter(&b2)
    w2.Close()

    r1, _ := gzip.NewReader(&b1)
    fmt.Println("Comment:", r1.Header.Comment) // Should be "Hello"

    r1.Reset(bytes.NewReader(b2.Bytes()))
    fmt.Println("Comment:", r1.Header.Comment) // Should be "", but prints "Hello"

    r2, _ := gzip.NewReader(bytes.NewReader(b2.Bytes()))
    fmt.Println("Comment:", r2.Header.Comment) // Should be ""

If the Reader previously decoded a gzip Reader.Header and Reset is used, the header from the previous use of gzip may leak into the next use of Reader.

We should properly clear the Reader.Header with Reset.

@gopherbot
Copy link

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

@golang golang locked and limited conversation to collaborators Apr 3, 2017
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

2 participants