From 957643f523dfe1bd9b59c67ae03b61eff4046017 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 8 Dec 2014 19:36:08 +0100 Subject: [PATCH] crypto/rand.Reader may not return all entropy immediately --- cmd/syncthing/random.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/syncthing/random.go b/cmd/syncthing/random.go index 4bba8c93..157056bf 100644 --- a/cmd/syncthing/random.go +++ b/cmd/syncthing/random.go @@ -19,6 +19,7 @@ import ( "crypto/md5" cryptoRand "crypto/rand" "encoding/binary" + "io" mathRand "math/rand" ) @@ -48,7 +49,7 @@ func randomString(l int) string { // randomInt64 returns a strongly random int64, slowly func randomInt64() int64 { var bs [8]byte - n, err := cryptoRand.Reader.Read(bs[:]) + n, err := io.ReadFull(cryptoRand.Reader, bs[:]) if n != 8 || err != nil { panic("randomness failure") }