mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 01:58:20 +00:00
GH-1076: Fix bro_srandom() to replace 0 seeds with 1
The bro_prng() implementation cannot generate 0 as a result since it causes every subsequent number from the PRNG to also be 0, so use the number 1 instead of 0.
This commit is contained in:
parent
0f4eb9af02
commit
887b53b7f3
3 changed files with 11 additions and 2 deletions
|
@ -1072,7 +1072,7 @@ static unsigned int first_seed = 0;
|
|||
|
||||
static void bro_srandom(unsigned int seed, bool deterministic)
|
||||
{
|
||||
bro_rand_state = seed;
|
||||
bro_rand_state = seed == 0 ? 1 : seed;
|
||||
bro_rand_determistic = deterministic;
|
||||
|
||||
srandom(seed);
|
||||
|
@ -1081,7 +1081,7 @@ static void bro_srandom(unsigned int seed, bool deterministic)
|
|||
void bro_srandom(unsigned int seed)
|
||||
{
|
||||
if ( bro_rand_determistic )
|
||||
bro_rand_state = seed;
|
||||
bro_rand_state = seed == 0 ? 1 : seed;
|
||||
else
|
||||
srandom(seed);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue