Skip to content

Commit

Permalink
fix: switch to crypto/rand from math/rand for some parts of the fuzz …
Browse files Browse the repository at this point in the history
…testing
  • Loading branch information
aschmahmann committed Jun 26, 2023
1 parent 0962474 commit bd1314e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mfs/mfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package mfs
import (
"bytes"
"context"
crand "crypto/rand"
"encoding/binary"
"errors"
"fmt"
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit bd1314e

Please sign in to comment.