mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +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:
@@ -90,17 +90,16 @@ next(void) {
|
|||||||
}
|
}
|
||||||
void
|
void
|
||||||
isc__random_initialize(void) {
|
isc__random_initialize(void) {
|
||||||
int useed[4] = { 0, 0, 0, 1 };
|
|
||||||
#if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
#if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
/*
|
/*
|
||||||
* Set a constant seed to help in problem reproduction should fuzzing
|
* A fixed seed helps with problem reproduction when fuzzing. It must be
|
||||||
* find a crash or a hang. The seed array must be non-zero else
|
* non-zero else xoshiro128starstar will generate only zeroes, and the
|
||||||
* xoshiro128starstar will generate an infinite series of zeroes.
|
* first result needs to be non-zero as expected by random_test.c
|
||||||
*/
|
*/
|
||||||
|
seed[0] = 1;
|
||||||
#else /* if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
#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 */
|
#endif /* if FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
||||||
memmove(seed, useed, sizeof(seed));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
uint8_t
|
||||||
|
Reference in New Issue
Block a user