E562
Skip to content

Conversation

@halvfigur
Copy link

If a caller passed in a map retained within the caller's context as extraHeaders to gin.Context.DataFromReader() then a race to write the "Content-Lenght" header would occur.

// globalHeader is passed to gin.Context.DataFromReader
var globalHeaders = map[string]string{
"cache-control": "public, max-age=3600",
}

func (c *gin.Context) {
//...

// DataFromReader must not write to globalHeaders
c.DataFromReader(code, contentLength, contentType, reader,
globalHeaders)

}

  • With pull requests:
    • Open your pull request against master
    • Your pull request should have no more than two commits, if not you should squash them.
    • It should pass all tests in the available continuous integration systems such as GitHub Actions.
    • You should add/modify tests to cover your proposed code changes.
    • If your pull request contains a new feature, please document it on the README.

If a caller passed in a map retained within the callers context as
extraHeaders to gin.Context.DataFromReader() then a race to write the
"Content-Lenght" header would occur.

// globalHeader is passed to gin.Context.DataFromReader
var globalHeaders = map[string]string{
    "cache-control": "public, max-age=3600",
}

func (c *gin.Context) {
    //...

    // DataFromReader must not write to globalHeaders
    c.DataFromReader(code, contentLength, contentType, reader,
	globalHeaders)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0