============================================================================= Deterministic RNG seeding from fuzz inputs ============================================================================= newRandFromSeed derives a deterministic *rand.Rand from the fuzz inputs. This lets the fuzz body make
(seeds ...[]byte)
| 127 | // coverage feedback remains meaningful). Uses FNV-1a for speed (no allocs |
| 128 | // beyond the rand.Rand struct itself). |
| 129 | func 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) |
no outgoing calls
no test coverage detected