diff options
author | Tzu-Chiao Yeh <su3g4284zo6y7@gmail.com> | 2020-09-02 10:53:39 +0800 |
---|---|---|
committer | Emmanuel Odeke <emm.odeke@gmail.com> | 2020-09-02 10:07:50 +0000 |
commit | 7432bee7b372efbbd09b16c4e3176b69fbb6878a (patch) | |
tree | c28195df679526a523a7ea721326dbbc546703a1 | |
parent | b246c0e12fd41caf45a0f81eaa4f8fe249fbbc01 (diff) | |
download | go-7432bee7b372efbbd09b16c4e3176b69fbb6878a.tar.gz go-7432bee7b372efbbd09b16c4e3176b69fbb6878a.zip |
net/http/fcgi: fix race in child.serve connection read
Guards the connection read with a mutex, because typeStdin
asynchronously and concurrently writes to the underlying conn.
Fixes #41167
Change-Id: Ia2610f4fde0bd4b108c54164095ea293980b0301
Reviewed-on: https://go-review.googlesource.com/c/go/+/252417
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
-rw-r--r-- | src/net/http/fcgi/child.go | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/net/http/fcgi/child.go b/src/net/http/fcgi/child.go index 30a6b2ce2d..0e91042543 100644 --- a/src/net/http/fcgi/child.go +++ b/src/net/http/fcgi/child.go @@ -155,9 +155,12 @@ func (c *child) serve() { defer c.cleanUp() var rec record for { + c.conn.mutex.Lock() if err := rec.read(c.conn.rwc); err != nil { + c.conn.mutex.Unlock() return } + c.conn.mutex.Unlock() if err := c.handleRecord(&rec); err != nil { return } |