Fix data race (#26)

Copy slice returned by defaultCipherSuitesTLS13 before modifying to
prevent data race against underlying varDefaultCipherSuitesTLS13 global
variable.
This commit is contained in:
Rod Hynes 2019-03-17 17:38:08 -04:00 committed by sergeyfrolov
parent 7c97cdb476
commit f8425e69f7

View file

@ -513,7 +513,8 @@ func (uconn *UConn) generateRandomizedSpec() (ClientHelloSpec, error) {
if r.FlipWeightedCoin(0.4) {
p.TLSVersMin = VersionTLS10
p.TLSVersMax = VersionTLS13
tls13ciphers := defaultCipherSuitesTLS13()
tls13ciphers := make([]uint16, len(defaultCipherSuitesTLS13()))
copy(tls13ciphers, defaultCipherSuitesTLS13())
r.rand.Shuffle(len(tls13ciphers), func(i, j int) {
tls13ciphers[i], tls13ciphers[j] = tls13ciphers[j], tls13ciphers[i]
})