From 275600b6c7d5308d6c43caa8f9451bf944204437 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 16 Sep 2011 08:11:26 +0200 Subject: 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. --- src/proto_http.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/proto_http.c b/src/proto_http.c index bf21ca9..2cd58d2 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++; } -- 1.7.2.3