mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-23 06:41:32 +02:00
BUG/MINOR: tools: fix statistical_prng_range()'s output range
This function was added by commit 84ebfabf7 ("MINOR: tools: add statistical_prng_range() to get a random number over a range") but it contains a bug on the range, since mul32hi() covers the whole input range, we must pass it range-1. For now it didn't have any impact, but if used to find an array's index it will cause trouble. This should be backported to 2.4.
This commit is contained in:
parent
4348232231
commit
03f3049df1
@ -1063,7 +1063,7 @@ static inline unsigned int statistical_prng()
|
||||
*/
|
||||
static inline uint statistical_prng_range(uint range)
|
||||
{
|
||||
return mul32hi(statistical_prng(), range);
|
||||
return mul32hi(statistical_prng(), range ? range - 1 : 0);
|
||||
}
|
||||
|
||||
/* Update array <fp> with the character transition <prev> to <curr>. If <prev>
|
||||
|
Loading…
x
Reference in New Issue
Block a user