From: Willy Tarreau Date: Thu, 6 Sep 2018 08:48:15 +0000 (+0200) Subject: BUG/MINOR: h1: fix buffer shift after realignment X-Git-Tag: v1.9-dev2~79 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=950a8a6fde81054ed28862a2ab7e24df95e1f1c8;p=thirdparty%2Fhaproxy.git BUG/MINOR: h1: fix buffer shift after realignment Commit 5e74b0b ("MEDIUM: h1: port to new buffer API.") introduced a minor bug by which a buffer's head could stay shifted by the amount of removed CRLF if it started with empty lines. This would cause the second request (or response) not to work until it would receive a few extra characters. This most only impacts requests sent by hand though. This is purely 1.9, no backport is needed. --- diff --git a/src/h1.c b/src/h1.c index 0d41d0bb1a..63ff99399b 100644 --- a/src/h1.c +++ b/src/h1.c @@ -457,11 +457,10 @@ void http_msg_analyzer(struct http_msg *msg, struct hdr_idx *idx) { enum h1_state state; /* updated only when leaving the FSM */ register const char *ptr, *end; /* request pointers, to avoid dereferences */ - char *input = (char *)ci_head(msg->chn); - struct buffer *buf; + struct buffer *buf = &msg->chn->buf; + char *input = b_head(buf); state = msg->msg_state; - buf = &msg->chn->buf; ptr = input + msg->next; end = b_stop(buf); @@ -486,6 +485,7 @@ void http_msg_analyzer(struct http_msg *msg, struct hdr_idx *idx) goto http_msg_ood; /* Remove empty leading lines, as recommended by RFC2616. */ b_del(buf, ptr - input); + input = b_head(buf); } msg->sol = 0; msg->sl.st.l = 0; /* used in debug mode */ @@ -554,6 +554,7 @@ void http_msg_analyzer(struct http_msg *msg, struct hdr_idx *idx) goto http_msg_ood; /* Remove empty leading lines, as recommended by RFC2616. */ b_del(buf, ptr - input); + input = b_head(buf); } msg->sol = 0; msg->sl.rq.l = 0; /* used in debug mode */