archive/zip, crypto/tls: use rand.Read instead of casting ints to bytes

Makes tests run ~1ms faster.

Change-Id: Ida509952469540280996d2bd9266724829e53c91
Reviewed-on: https://go-review.googlesource.com/47359
Reviewed-by: Filippo Valsorda <hi@filippo.io>
Run-TryBot: Filippo Valsorda <hi@filippo.io>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Carl Mastrangelo 2017-07-03 15:38:55 -07:00 committed by Filippo Valsorda
parent 00b53d39c3
commit 5731b5256b

View File

@ -98,8 +98,8 @@ func TestFuzz(t *testing.T) {
func randomBytes(n int, rand *rand.Rand) []byte { func randomBytes(n int, rand *rand.Rand) []byte {
r := make([]byte, n) r := make([]byte, n)
for i := 0; i < n; i++ { if _, err := rand.Read(r); err != nil {
r[i] = byte(rand.Int31()) panic("rand.Read failed: " + err.Error())
} }
return r return r
} }