From 7fc1c6eefb7f3b64dee8f3a4a31e3b7f5a65dc2e Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 26 Apr 2012 11:03:17 +0200 Subject: [PATCH] MINOR: stick_table: centralize the handling of empty keys Right now, it's up to each pattern fetch method to return NULL when an empty string is returned, which is neither correct nor desirable as it is only stick tables which need to ignore empty patterns. Let's perform this check in stktable_fetch_key() instead. --- src/stick_table.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stick_table.c b/src/stick_table.c index a6ae3a2979..1cb240b6aa 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -609,6 +609,9 @@ 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 == 0) + return NULL; + if ((static_table_key.key_len < t->key_size) && (t->type != STKTABLE_TYPE_STRING)) { /* need padding with null */ @@ -635,7 +638,6 @@ struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, st memset(static_table_key.key + static_table_key.key_len, 0, t->key_size - static_table_key.key_len); } - return &static_table_key; }