]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] backend: L7 hashing must not be performed on incomplete requests
authorWilly Tarreau <w@1wt.eu>
Wed, 24 Mar 2010 13:54:30 +0000 (14:54 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 25 Mar 2010 05:32:52 +0000 (06:32 +0100)
Isidore Li reported an occasional segfault when using URL hashing, and
kindly provided backtraces and core files to help debugging.

The problem was triggered by reset connections before the URL was sent,
and was due to the same bug which was fixed by commit e45997661bf
(connections were attempted in case of connection abort). While that
bug was already fixed, it appeared that the same segfault could be
triggered when URL hashing is configured in an HTTP backend when the
frontend runs in TCP mode and no URL was seen. It is totally abnormal
to try to hash a null URL, as well as to process any kind of L7 hashing
when a full request was not seen.

This additional fix now ensures that layer7 hashing is not performed on
incomplete requests.

src/backend.c

index 8b8b4377bb245d04521405b70e7ea0d433d37d93..1a8653762c2aa4d52ad0b5127bdc8e89b549cb69 100644 (file)
@@ -534,6 +534,8 @@ int assign_server(struct session *s)
 
                        case BE_LB_HASH_URI:
                                /* URI hashing */
+                               if (s->txn.req.msg_state < HTTP_MSG_BODY)
+                                       break;
                                s->srv = get_server_uh(s->be,
                                                       s->txn.req.sol + s->txn.req.sl.rq.u,
                                                       s->txn.req.sl.rq.u_l);
@@ -541,6 +543,8 @@ int assign_server(struct session *s)
 
                        case BE_LB_HASH_PRM:
                                /* URL Parameter hashing */
+                               if (s->txn.req.msg_state < HTTP_MSG_BODY)
+                                       break;
                                if (s->txn.meth == HTTP_METH_POST &&
                                    memchr(s->txn.req.sol + s->txn.req.sl.rq.u, '&',
                                           s->txn.req.sl.rq.u_l ) == NULL)
@@ -553,6 +557,8 @@ int assign_server(struct session *s)
 
                        case BE_LB_HASH_HDR:
                                /* Header Parameter hashing */
+                               if (s->txn.req.msg_state < HTTP_MSG_BODY)
+                                       break;
                                s->srv = get_server_hh(s);
                                break;