mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-22 13:46:52 +00:00
[BUG] stick-table: correctly terminate string keys during lookups
If a key to be looked up is extracted from data without being padded and if it matches the beginning of another stored key, it is not found in subsequent lookups because it does not end with a zero. This bug was discovered and diagnosed by David Cournapeau.
This commit is contained in:
parent
48936af9a2
commit
035da6d1b0
@ -560,7 +560,13 @@ struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, st
|
||||
if (!static_table_key.key)
|
||||
return NULL;
|
||||
|
||||
if ((static_table_key.key_len < t->key_size) && (t->type != STKTABLE_TYPE_STRING)) {
|
||||
if (t->type == STKTABLE_TYPE_STRING) {
|
||||
/* The string MUST be terminated by a '\0' after the key_len bytes */
|
||||
if (static_table_key.key_len > t->key_size - 1)
|
||||
static_table_key.key_len = t->key_size - 1;
|
||||
((char *)static_table_key.key)[static_table_key.key_len] = 0;
|
||||
}
|
||||
else if (static_table_key.key_len < t->key_size) {
|
||||
/* need padding with null */
|
||||
|
||||
/* assume static_table_key.key_len is less than sizeof(static_table_key.data.buf)
|
||||
|
Loading…
Reference in New Issue
Block a user