mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
crypto/rand.Reader may not return all entropy immediately
This commit is contained in:
parent
749bbec566
commit
957643f523
@ -19,6 +19,7 @@ import (
|
|||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
cryptoRand "crypto/rand"
|
cryptoRand "crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"io"
|
||||||
mathRand "math/rand"
|
mathRand "math/rand"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -48,7 +49,7 @@ func randomString(l int) string {
|
|||||||
// randomInt64 returns a strongly random int64, slowly
|
// randomInt64 returns a strongly random int64, slowly
|
||||||
func randomInt64() int64 {
|
func randomInt64() int64 {
|
||||||
var bs [8]byte
|
var bs [8]byte
|
||||||
n, err := cryptoRand.Reader.Read(bs[:])
|
n, err := io.ReadFull(cryptoRand.Reader, bs[:])
|
||||||
if n != 8 || err != nil {
|
if n != 8 || err != nil {
|
||||||
panic("randomness failure")
|
panic("randomness failure")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user