From f8425e69f7d4eff4e1988c6c4ca1ca9a6e17a42f Mon Sep 17 00:00:00 2001 From: Rod Hynes Date: Sun, 17 Mar 2019 17:38:08 -0400 Subject: [PATCH] Fix data race (#26) Copy slice returned by defaultCipherSuitesTLS13 before modifying to prevent data race against underlying varDefaultCipherSuitesTLS13 global variable. --- u_parrots.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/u_parrots.go b/u_parrots.go index 1b82ff8..b744ee8 100644 --- a/u_parrots.go +++ b/u_parrots.go @@ -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] })