From 68b1bbd767c1d863bbbe98e6255a2511fe99e3aa Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Fri, 4 Jan 2019 16:06:48 +0100 Subject: [PATCH] BUG/MEDIUM: h1: Get the h1m state when restarting the headers parsing Since the commit 0f8fb6b7f ("MINOR: h1: make the H1 headers block parser able to parse headers only"), when headers are not received in one time, a parsing error is returned because the local state in the function h1_headers_to_hdr_list() was not initialized with the previous one (in fact, it was not initialized at all). So now, we start the parsing of headers with the state H1_MSG_HDR_FIRST when the flag H1_MF_HDRS_ONLY is set. Otherwise, we always get it from the h1m. This patch must be backported to 1.9. --- src/h1.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/h1.c b/src/h1.c index f9e8c9c0f..38d13c6c3 100644 --- a/src/h1.c +++ b/src/h1.c @@ -272,10 +272,11 @@ int h1_headers_to_hdr_list(char *start, const char *stop, state = H1_MSG_HDR_FIRST; h1m->next = 0; } - else if (h1m->state == H1_MSG_RQBEFORE || h1m->state == H1_MSG_RPBEFORE) + else { state = h1m->state; - else - restarting = 1; + if (h1m->state != H1_MSG_RQBEFORE && h1m->state != H1_MSG_RPBEFORE) + restarting = 1; + } ptr = start + h1m->next; end = stop;