From: William Lallemand Date: Wed, 9 Mar 2022 17:56:02 +0000 (+0100) Subject: BUG/MINOR: httpclient: remove the UNUSED block when parsing headers X-Git-Tag: v2.6-dev4~77 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c020b2505d4d5a94d1b465a4e6e73c1f5ef86170;p=thirdparty%2Fhaproxy.git BUG/MINOR: httpclient: remove the UNUSED block when parsing headers Remove the UNUSED blocks when iterating on headers, we should not stop when encountering one. We should only stop iterating once we found the EOH block. It doesn't provoke a problem, since we don't manipulates the headers before treating them, but it could evolve in the future. Must be backported to 2.5. --- diff --git a/src/http_client.c b/src/http_client.c index f17e805e6d..94b192a6c7 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -787,24 +787,29 @@ static void httpclient_applet_io_handler(struct appctx *appctx) enum htx_blk_type type = htx_get_blk_type(blk); uint32_t sz = htx_get_blksz(blk); + if (type == HTX_BLK_UNUSED) { + c_rew(res, sz); + htx_remove_blk(htx, blk); + } + + if (type == HTX_BLK_HDR) { + hdrs[hdr_num].n = istdup(htx_get_blk_name(htx, blk)); + hdrs[hdr_num].v = istdup(htx_get_blk_value(htx, blk)); + if (!isttest(hdrs[hdr_num].v) || !isttest(hdrs[hdr_num].n)) + goto end; + c_rew(res, sz); + htx_remove_blk(htx, blk); + hdr_num++; + } + + /* create a NULL end of array and leave the loop */ if (type == HTX_BLK_EOH) { hdrs[hdr_num].n = IST_NULL; hdrs[hdr_num].v = IST_NULL; - co_set_data(res, co_data(res) - sz); + c_rew(res, sz); htx_remove_blk(htx, blk); break; } - - if (type != HTX_BLK_HDR) - break; - - hdrs[hdr_num].n = istdup(htx_get_blk_name(htx, blk)); - hdrs[hdr_num].v = istdup(htx_get_blk_value(htx, blk)); - if (!isttest(hdrs[hdr_num].v) || !isttest(hdrs[hdr_num].n)) - goto end; - co_set_data(res, co_data(res) - sz); - htx_remove_blk(htx, blk); - hdr_num++; } if (hdr_num) {