syncthing / syncthing

Audit the random number generation source (rand) GSC-G404
Security
Minor
3 occurrences in this check
Use of weak random number generator (math/rand instead of crypto/rand)
 300		return
 301	}
 302	// Sleep a random time between 3/4 and 5/4 of the configured interval.
 303	sleepNanos := (f.scanInterval.Nanoseconds()*3 + rand.Int63n(2*f.scanInterval.Nanoseconds())) / 4 304	interval := time.Duration(sleepNanos) * time.Nanosecond
 305	l.Debugln(f, "next rescan in", interval)
 306	f.scanTimer.Reset(interval)
Use of weak random number generator (math/rand instead of crypto/rand)
133		// *look* like file I/O, but they are not. Do not worry that they
134		// might fail.
135
136		rng := rand.New(rand.NewSource(int64(seed)))137		var createdFiles int
138		var writtenData int64
139		for (files == 0 || createdFiles < files) && (maxsize == 0 || writtenData>>20 < int64(maxsize)) {
Use of weak random number generator (math/rand instead of crypto/rand)
789	nextBlockOffs := (seedNo + 1) << randomBlockShift
790	if f.rng == nil || f.offset != offs || seedNo != f.seedOffs {
791		// This is not a straight read continuing from a previous one
792		f.rng = rand.New(rand.NewSource(f.seed + seedNo))793
794		// If the read is not at the start of the block, discard data
795		// accordingly.