mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
BUG/MINOR: stick-tables: Missing stick-table key nullity check
This bug arrived with this commit: MAJOR: stktable: split the keys across multiple shards to reduce contention At this time, there are no callers which call stktable_get_entry() without checking the nullity of <key> passed as parameter. But the documentation of this function says it supports this case where the <key> passed as parameter could be null. Move the nullity test on <key> at first statement of this function. Thanks to @chipitsine for having reported this issue in GH #2518.
This commit is contained in:
parent
ba1a0559e4
commit
fcb096f7cd
@ -699,6 +699,9 @@ struct stksess *stktable_get_entry(struct stktable *table, struct stktable_key *
|
|||||||
uint shard;
|
uint shard;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
|
if (!key)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
if (table->type == SMP_T_STR)
|
if (table->type == SMP_T_STR)
|
||||||
len = key->key_len + 1 < table->key_size ? key->key_len : table->key_size - 1;
|
len = key->key_len + 1 < table->key_size ? key->key_len : table->key_size - 1;
|
||||||
else
|
else
|
||||||
@ -706,9 +709,6 @@ struct stksess *stktable_get_entry(struct stktable *table, struct stktable_key *
|
|||||||
|
|
||||||
shard = stktable_calc_shard_num(table, key->key, len);
|
shard = stktable_calc_shard_num(table, key->key, len);
|
||||||
|
|
||||||
if (!key)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
HA_RWLOCK_RDLOCK(STK_TABLE_LOCK, &table->shards[shard].sh_lock);
|
HA_RWLOCK_RDLOCK(STK_TABLE_LOCK, &table->shards[shard].sh_lock);
|
||||||
ts = __stktable_lookup_key(table, key, shard);
|
ts = __stktable_lookup_key(table, key, shard);
|
||||||
if (ts)
|
if (ts)
|
||||||
|
Loading…
Reference in New Issue
Block a user