Skip to content

Fix cache corruption due to recorder reuse#1146

Merged
kataras merged 1 commit intokataras:masterfrom
hendrikhofstadt:patch-1
Dec 2, 2018
Merged

Fix cache corruption due to recorder reuse#1146
kataras merged 1 commit intokataras:masterfrom
hendrikhofstadt:patch-1

Conversation

@hendrikhofstadt
Copy link
Copy Markdown
Contributor

Currently, the body of a cache entry is set to the chunks of a request recorder.

body := recorder.Body() // <- recorder.chunks (which is reused)

e.response.body = body

However recorders are reused. If now a recorder is being reused and a cache entry points to a slice of the same array that is used to record the new request the cache entry is overwritten thereby corrupting the cache.

We need to copy the body to avoid this and make the cache entry immutable.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 29, 2018

CLA assistant check
All committers have signed the CLA.

@kataras kataras merged commit fd470c4 into kataras:master Dec 2, 2018
@kataras
Copy link
Copy Markdown
Owner

kataras commented Dec 2, 2018

Thanks @SLAMPER !

github-actions Bot pushed a commit to goproxies/github.com-kataras-iris that referenced this pull request Jul 27, 2020
Fix cache corruption due to recorder reuse

Former-commit-id: e010b13230f93e0dab208bc1558aca094efc1667
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.

3 participants