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

net/http: request.Clone doesn't deep copy TransferEncoding #41907

Closed
dqu123 opened this issue Oct 10, 2020 · 5 comments
Closed

net/http: request.Clone doesn't deep copy TransferEncoding #41907

dqu123 opened this issue Oct 10, 2020 · 5 comments
Labels
Milestone

Comments

@dqu123
Copy link
Contributor

@dqu123 dqu123 commented Oct 10, 2020

What version of Go are you using (go version)?

$ go version
go version go1.14.5 darwin/amd64

Does this issue reproduce with the latest release?

yes, bug exists in master: https://github.com/golang/go/blob/master/src/net/http/request.go#L385

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/david/Library/Caches/go-build"
GOENV="/Users/david/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/david/cs/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.14.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.14.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/5r/35kn30hd119486nmd0sjcy8c0000gn/T/go-build221526405=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

What did you expect to see?

cloned request TransferEncoding should not changed by changes to the original request after it has been copied.

What did you see instead?

cloned request TransferEncoding was modified by changing original request TransferEncoding

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 10, 2020

Change https://golang.org/cl/261258 mentions this issue: net/http: deep copy Request.TransferEncoding

@dqu123 dqu123 changed the title http: request.Clone doesn't deep copy TransferEncoding net/http: request.Clone doesn't deep copy TransferEncoding Oct 10, 2020
@odeke-em
Copy link
Member

@odeke-em odeke-em commented Oct 10, 2020

Thank you for catching this @dqu123 and welcome to the Go project! Good eyes.

@gopherbot please backport this issue.

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 10, 2020

Backport issue(s) opened: #41913 (for 1.14), #41914 (for 1.15).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@odeke-em odeke-em added the NeedsFix label Oct 10, 2020
@gopherbot
Copy link

@gopherbot gopherbot commented Oct 11, 2020

Change https://golang.org/cl/261377 mentions this issue: net/http: deep copy Request.TransferEncoding

@gopherbot
Copy link

@gopherbot gopherbot commented Oct 11, 2020

Change https://golang.org/cl/261378 mentions this issue: net/http: deep copy Request.TransferEncoding

@gopherbot gopherbot closed this in 0f53453 Oct 12, 2020
gopherbot pushed a commit that referenced this issue Oct 23, 2020
The existing implementation in Request.Clone() assigns the wrong
pointer to r2.TransferEncoding.

Updates #41907.
Fixes #41914.

Change-Id: I7f220a41b1b46a55d1a1005e47c6dd69478cb025
Reviewed-on: https://go-review.googlesource.com/c/go/+/261378
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
gopherbot pushed a commit that referenced this issue Oct 23, 2020
The existing implementation in Request.Clone() assigns the wrong
pointer to r2.TransferEncoding.

Updates #41907.
Fixes #41913.

Change-Id: I7f220a41b1b46a55d1a1005e47c6dd69478cb025
Reviewed-on: https://go-review.googlesource.com/c/go/+/261377
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Carlos Amedee <carlos@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants