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.
This commit is contained in:
Willy Tarreau 2011-09-16 08:11:26 +02:00
parent 85c27da67e
commit 275600b6c7

View 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++;
}