mirror of
https://github.com/rclone/rclone.git
synced 2025-11-23 21:44:49 +02:00
random: stop using deprecated rand.Seed in go1.20 and later
This commit is contained in:
@@ -67,19 +67,3 @@ func Password(bits int) (password string, err error) {
|
||||
password = base64.RawURLEncoding.EncodeToString(pw)
|
||||
return password, nil
|
||||
}
|
||||
|
||||
// Seed the global math/rand with crypto strong data
|
||||
//
|
||||
// This doesn't make it OK to use math/rand in crypto sensitive
|
||||
// environments - don't do that! However it does help to mitigate the
|
||||
// problem if that happens accidentally. This would have helped with
|
||||
// CVE-2020-28924 - #4783
|
||||
func Seed() error {
|
||||
var seed int64
|
||||
err := binary.Read(cryptorand.Reader, binary.LittleEndian, &seed)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read random seed: %w", err)
|
||||
}
|
||||
mathrand.Seed(seed)
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user