]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: h1: fix buffer shift after realignment
authorWilly Tarreau <w@1wt.eu>
Thu, 6 Sep 2018 08:48:15 +0000 (10:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 6 Sep 2018 08:48:15 +0000 (10:48 +0200)
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.

src/h1.c

index 0d41d0bb1a4b59c10b26c9063db1f30951b8767d..63ff99399be5bb07a76118448f7988543120e3ee 100644 (file)
--- 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 */