mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-03-01 17:10:42 +00:00
MINOR: vars: preset a random seed to hash variables names
Variables names will be hashed, but for this we need a random seed. The XXH3() algorithms is bijective over the whole 64-bit space, which is great as it guarantees no collision for 1..8 byte names. But above that even if the risk is extremely faint, it theoretically exists and since variables may be set from Lua we'd rather do our best to limit the risk of controlled collision, hence the random seed.
This commit is contained in:
parent
df8eeb1619
commit
2c897d9d1b
@ -42,6 +42,7 @@ static unsigned int var_sess_limit = 0;
|
||||
static unsigned int var_txn_limit = 0;
|
||||
static unsigned int var_reqres_limit = 0;
|
||||
static unsigned int var_check_limit = 0;
|
||||
static uint64_t var_name_hash_seed = 0;
|
||||
|
||||
__decl_rwlock(var_names_rwlock);
|
||||
|
||||
@ -1223,6 +1224,14 @@ static int vars_max_size_check(char **args, int section_type, struct proxy *curp
|
||||
return vars_max_size(args, section_type, curpx, defpx, file, line, err, &var_check_limit);
|
||||
}
|
||||
|
||||
/* early boot initialization */
|
||||
static void vars_init()
|
||||
{
|
||||
var_name_hash_seed = ha_random64();
|
||||
}
|
||||
|
||||
INITCALL0(STG_PREPARE, vars_init);
|
||||
|
||||
static void vars_deinit()
|
||||
{
|
||||
while (var_names_nb-- > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user