]> Cypherpunks repositories - gostls13.git/commit
net/textproto: initialize commonHeader in canonicalMIMEHeaderKey
authorJohan Jansson <johan.jansson@iki.fi>
Fri, 1 Apr 2022 11:00:09 +0000 (14:00 +0300)
committerGopher Robot <gobot@golang.org>
Fri, 8 Apr 2022 21:40:11 +0000 (21:40 +0000)
commitdb576c9f3a33d043b4dc6cd8177f4e0b25ded8ec
tree662cb4ebdd1ff4934312e1c477c5099225ae7ca0
parent3a19102de3435a3823126e74cf42c67037ff1890
net/textproto: initialize commonHeader in canonicalMIMEHeaderKey

Call initCommonHeader in canonicalMIMEHeaderKey to ensure that
commonHeader is initialized before use. Remove all other calls to
initCommonHeader, since commonHeader is only used in
canonicalMIMEHeaderKey.

This prevents a race condition: read of commonHeader before
commonHeader has been initialized.

Add regression test that triggers the race condition which can be
detected by the race detector.

Fixes #46363

Change-Id: I00c8c52c6f4c78c0305978c876142c1b388174af
Reviewed-on: https://go-review.googlesource.com/c/go/+/397575
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/net/textproto/reader.go
src/net/textproto/reader_test.go