]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[REVERT] undo the stick-table string key lookup fixes
authorWilly Tarreau <w@1wt.eu>
Tue, 4 Jan 2011 13:50:49 +0000 (14:50 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 4 Jan 2011 13:50:49 +0000 (14:50 +0100)
Revert commits 035da6d1b0c436b85add48bc22120aa814c9cab9 and
f18b5f21bafef909901b7b5cf95625a63e609c75.

These fixes were wrong. They worked but they were fixing the symptom
instead of the root cause of the problem. The real issue was in the
ebtree lookup code and it has been fixed now so these patches are not
needed anymore. It's better not to copy memory blocks when we don't
need to, so let's revert them.

src/stick_table.c

index f080095b195f97f993f5c6e3ba38b93126e1c13a..7c9ad8da0dfadd135a7fa02c2ea57564c0d45d0b 100644 (file)
@@ -560,25 +560,7 @@ struct stktable_key *stktable_fetch_key(struct stktable *t, struct proxy *px, st
        if (!static_table_key.key)
                return NULL;
 
-       if (t->type == STKTABLE_TYPE_STRING) {
-               /* The string MUST be terminated by a '\0' after the key_len bytes. The problem
-                * is that we cannot modify the input data if it comes from the original buffer,
-                * so we copy it to a private buffer if required.
-                */
-               if (static_table_key.key_len > t->key_size - 1)
-                       static_table_key.key_len = t->key_size - 1;
-
-               if (((char *)static_table_key.key)[static_table_key.key_len] != 0) {
-                       if ((char *)static_table_key.key < (char *)&static_table_key.data ||
-                           (char *)static_table_key.key >  (char *)&static_table_key.data + sizeof(static_table_key.data)) {
-                               /* key definitly not part of the static_table_key private data buffer */
-                               memcpy(static_table_key.data.buf, static_table_key.key, static_table_key.key_len);
-                               static_table_key.key = static_table_key.data.buf;
-                       }
-                       ((char *)static_table_key.key)[static_table_key.key_len] = 0;
-               }
-       }
-       else if (static_table_key.key_len < t->key_size) {
+       if ((static_table_key.key_len < t->key_size) && (t->type != STKTABLE_TYPE_STRING)) {
                /* need padding with null */
 
                /* assume static_table_key.key_len is less than sizeof(static_table_key.data.buf)