From bd1314e5a00da51984c67e327952c52aea3c1005 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Mon, 26 Jun 2023 10:16:28 -0400 Subject: [PATCH] fix: switch to crypto/rand from math/rand for some parts of the fuzz testing --- mfs/mfs_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mfs/mfs_test.go b/mfs/mfs_test.go index fd835f3ec..e57404b82 100644 --- a/mfs/mfs_test.go +++ b/mfs/mfs_test.go @@ -3,6 +3,7 @@ package mfs import ( "bytes" "context" + crand "crypto/rand" "encoding/binary" "errors" "fmt" @@ -629,8 +630,6 @@ func TestMfsDirListNames(t *testing.T) { rootdir := rt.GetDirectory() - rand.Seed(time.Now().UTC().UnixNano()) - total := rand.Intn(10) + 1 fNames := make([]string, 0, total) @@ -789,7 +788,9 @@ func actorWriteFile(d *Directory) error { size := rand.Intn(1024) + 1 buf := make([]byte, size) - rand.Read(buf) + if _, err := crand.Read(buf); err != nil { + return err + } s, err := fi.Size() if err != nil { @@ -1067,8 +1068,9 @@ func TestConcurrentReads(t *testing.T) { d := mkdirP(t, rootdir, path) buf := make([]byte, 2048) - rand.Read(buf) - + if _, err := crand.Read(buf); err != nil { + t.Fatal(err) + } fi := fileNodeFromReader(t, ds, bytes.NewReader(buf)) err := d.AddChild("afile", fi) if err != nil {