From 84f06533e169ce34afad9e48fa6d3b0f614d4ad0 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 3 Sep 2019 16:05:31 +0200 Subject: [PATCH] BUG/MINOR: h1: Properly reset h1m when parsing is restarted 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/h1.c b/src/h1.c index 957abd5b8..5bd54f632 100644 --- 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