mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 05:57:52 +00:00
Ensure the first random number is non-zero when fuzzing
In fuzzing mode, `isc_random` uses a fixed seed for reproducibility. The particular seed chosen happened to produce zero as its first number, however commit bd251de0 introduced an initialization check in `random_test` that required it to be non-zero. This change adjusts the seed to avoid spurious test failures. Also, remove the temporary variable that was used for initialization because it did not match the type of the thread-local seed array.
This commit is contained in:
parent
2ee16067c5
commit
4b9af22830
@ -90,17 +90,16 @@ next(void) {
|
||||
}
|
||||
void
|
||||
isc__random_initialize(void) {
|
||||
int useed[4] = { 0, 0, 0, 1 };
|
||||
#if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||
/*
|
||||
* Set a constant seed to help in problem reproduction should fuzzing
|
||||
* find a crash or a hang. The seed array must be non-zero else
|
||||
* xoshiro128starstar will generate an infinite series of zeroes.
|
||||
* A fixed seed helps with problem reproduction when fuzzing. It must be
|
||||
* non-zero else xoshiro128starstar will generate only zeroes, and the
|
||||
* first result needs to be non-zero as expected by random_test.c
|
||||
*/
|
||||
seed[0] = 1;
|
||||
#else /* if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
||||
isc_entropy_get(useed, sizeof(useed));
|
||||
isc_entropy_get(seed, sizeof(seed));
|
||||
#endif /* if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
||||
memmove(seed, useed, sizeof(seed));
|
||||
}
|
||||
|
||||
uint8_t
|
||||
|
Loading…
x
Reference in New Issue
Block a user