From: Willy Tarreau Date: Thu, 29 Jan 2015 13:01:34 +0000 (+0100) Subject: BUG/MINOR: http: fix incorrect header value offset in replace-hdr/replace-value X-Git-Tag: v1.6-dev1~161 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa435e7d7eb1a2dd5f2b9b8008e352a816946ccc;p=thirdparty%2Fhaproxy.git BUG/MINOR: http: fix incorrect header value offset in replace-hdr/replace-value The two http-req/http-resp actions "replace-hdr" and "replace-value" were expecting exactly one space after the colon, which is wrong. It was causing the first char not to be seen/modified when no space was present, and empty headers not to be modified either. Instead of using name->len+2, we must use ctx->val which points to the first character of the value even if there is no value. This fix must be backported into 1.5. --- diff --git a/src/proto_http.c b/src/proto_http.c index 3c8747841f..b8f5520154 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -3250,7 +3250,7 @@ static int http_transform_header(struct session* s, struct http_msg *msg, const while (http_find_full_header2(name, name_len, buf, idx, ctx)) { struct hdr_idx_elem *hdr = idx->v + ctx->idx; int delta; - char* val = (char*)ctx->line + name_len + 2; + char* val = (char*)ctx->line + ctx->val; char* val_end = (char*)ctx->line + hdr->len; char* reg_dst_buf; uint reg_dst_buf_size;