]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: don't trim last spaces from headers consisting only of spaces
authorWilly Tarreau <w@1wt.eu>
Fri, 16 Sep 2011 06:11:26 +0000 (08:11 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 16 Sep 2011 06:11:26 +0000 (08:11 +0200)
Commit 588bd4 fixed header parsing so that trailing spaces were not part
of the returned string. Unfortunately, if a header only had spaces, the
last spaces were trimmed past the beginning of the value, causing a negative
length to be returned.

A quick code review shows that there should be no impact since the only
places where the vlen is used are either compared to a specific value or
with explicit contents (eg: digits).

This must be backported to 1.4.

src/proto_http.c

index bf21ca9c830869d6a8a09e087248aeb92823f02e..2cd58d2c9b4b7db4fb79c9266c4757ec31535803 100644 (file)
@@ -552,7 +552,7 @@ int http_find_header2(const char *name, int len,
 
                        eol = find_hdr_value_end(sov, eol);
                        ctx->tws = 0;
-                       while (http_is_lws[(unsigned char)*(eol - 1)]) {
+                       while (eol > sov && http_is_lws[(unsigned char)*(eol - 1)]) {
                                eol--;
                                ctx->tws++;
                        }