]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: h1: Properly reset h1m when parsing is restarted
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 3 Sep 2019 14:05:31 +0000 (16:05 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 4 Sep 2019 08:30:11 +0000 (10:30 +0200)
Otherwise some processing may be performed twice. For instance, if the header
"Content-Length" is parsed on the first pass, when the parsing is restarted, we
skip it because we think another header with the same value was already seen. In
fact, it is currently the only existing bug that can be encountered. But it is
safer to reset all the h1m on restart to avoid any future bugs.

This patch must be backported to 2.0 and 1.9

src/h1.c

index 957abd5b813b3c307e47c6804478f5cf4d28907f..5bd54f63200e7cda84b1e57da3fd94fa38abcedb 100644 (file)
--- a/src/h1.c
+++ b/src/h1.c
@@ -934,7 +934,8 @@ int h1_headers_to_hdr_list(char *start, const char *stop,
        return -2;
 
  restart:
-       h1m->next  = 0;
+       h1m->flags &= ~(H1_MF_VER_11|H1_MF_CLEN|H1_MF_XFER_ENC|H1_MF_CHNK|H1_MF_CONN_KAL|H1_MF_CONN_CLO|H1_MF_CONN_UPG);
+       h1m->curr_len = h1m->body_len = h1m->next  = 0;
        if (h1m->flags & H1_MF_RESP)
                h1m->state = H1_MSG_RPBEFORE;
        else