From: Willy Tarreau Date: Sat, 15 Jun 2019 09:34:41 +0000 (+0200) Subject: BUG/MEDIUM: mux-h2: properly account for the appended data in HTX X-Git-Tag: v2.0.0~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b6563f4ac407a6096a2b2d5126729c2668dc0493;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: mux-h2: properly account for the appended data in HTX When commit 0350b90e3 ("MEDIUM: htx: make htx_add_data() never defragment the buffer") was introduced, it made htx_add_data() actually be able to add less data than it was asked for, and the callers must use the returned value to know how much was added. The H2 code used to rely on the frame length instead of the return value. A version of the code doing this was written but is obviously not the one that got merged, resulting in breaking large uploads or downloads when HTX would have instead defragmented the buffer because the HTX side sees less contents than what the H2 side sees. This patch fixes this again. No backport is needed. --- diff --git a/src/mux_h2.c b/src/mux_h2.c index 790d5bb95d..d02168df5a 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -3814,13 +3814,13 @@ try_again: sent = htx_add_data(htx, ist2(b_head(&h2c->dbuf), flen)); - b_del(&h2c->dbuf, flen); - h2c->dfl -= flen; - h2c->rcvd_c += flen; - h2c->rcvd_s += flen; // warning, this can also affect the closed streams! + b_del(&h2c->dbuf, sent); + h2c->dfl -= sent; + h2c->rcvd_c += sent; + h2c->rcvd_s += sent; // warning, this can also affect the closed streams! if (h2s->flags & H2_SF_DATA_CLEN) { - h2s->body_len -= flen; + h2s->body_len -= sent; htx->extra = h2s->body_len; }