MCPcopy Create free account
hub / github.com/buger/jsonparser / newRandFromSeed

Function newRandFromSeed

json_fuzz_test.go:129–142  ·  view source on GitHub ↗

============================================================================= Deterministic RNG seeding from fuzz inputs ============================================================================= newRandFromSeed derives a deterministic *rand.Rand from the fuzz inputs. This lets the fuzz body make

(seeds ...[]byte)

Source from the content-addressed store, hash-verified

127// coverage feedback remains meaningful). Uses FNV-1a for speed (no allocs
128// beyond the rand.Rand struct itself).
129func newRandFromSeed(seeds ...[]byte) *rand.Rand {
130 const (
131 offsetBasis uint64 = 14695981039346656037
132 fnvPrime uint64 = 1099511628211
133 )
134 h := offsetBasis
135 for _, s := range seeds {
136 for _, b := range s {
137 h ^= uint64(b)
138 h *= fnvPrime
139 }
140 }
141 return rand.New(rand.NewSource(int64(h)))
142}
143
144// =============================================================================
145// Recursive JSON value generator (grammar-based)

Callers 3

FuzzSequenceFunction · 0.85
FuzzJSONStructureAwareFunction · 0.85
FuzzEncodingJSONFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected