From: Willy Tarreau Date: Fri, 16 Sep 2011 06:11:26 +0000 (+0200) Subject: BUG/MEDIUM: don't trim last spaces from headers consisting only of spaces X-Git-Tag: v1.5-dev8~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=275600b6c7d5308d6c43caa8f9451bf944204437;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: don't trim last spaces from headers consisting only of spaces 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. --- diff --git a/src/proto_http.c b/src/proto_http.c index bf21ca9c83..2cd58d2c9b 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -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++; }