]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stick_table: centralize the handling of empty keys
authorWilly Tarreau <w@1wt.eu>
Thu, 26 Apr 2012 09:03:17 +0000 (11:03 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 8 May 2012 18:57:18 +0000 (20:57 +0200)
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

index a6ae3a29792ef7e1f30476bf1a7c24841740d44d..1cb240b6aa5f156b0f9860e27c9a668e7c09d24f 100644 (file)
@@ -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;
 }