From: Willy Tarreau Date: Thu, 26 Apr 2012 09:03:17 +0000 (+0200) Subject: MINOR: stick_table: centralize the handling of empty keys X-Git-Tag: v1.5-dev9~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fc1c6eefb7f3b64dee8f3a4a31e3b7f5a65dc2e;p=thirdparty%2Fhaproxy.git 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. --- 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; }