]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] http: update the header list's tail when removing the last header
authorWilly Tarreau <w@1wt.eu>
Sat, 12 Feb 2011 12:07:35 +0000 (13:07 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 12 Feb 2011 12:07:35 +0000 (13:07 +0100)
Stefan Behte reported a strange case where depending on the position of
the Connection header in the header list, some headers added after it
were or were not usable in "balance hdr()". The reason is that when the
last header is removed, the list's tail was not updated, so any header
added after that one was not visible from the list.

This fix must be backported to 1.4 and possibly 1.3.

src/proto_http.c

index c5debcaff57a1e32efaf875c97aa14b3d161db82..dbd6a2e81498182520d3aa3ef91dffcb9446529d 100644 (file)
@@ -601,6 +601,8 @@ int http_remove_header2(struct http_msg *msg, struct buffer *buf,
                idx->used--;
                hdr->len = 0;   /* unused entry */
                idx->v[ctx->prev].next = idx->v[ctx->idx].next;
+               if (idx->tail == ctx->idx)
+                       idx->tail = ctx->prev;
                ctx->idx = ctx->prev;    /* walk back to the end of previous header */
                ctx->line -= idx->v[ctx->idx].len + idx->v[cur_idx].cr + 1;
                ctx->val = idx->v[ctx->idx].len; /* point to end of previous header */