diff --git a/src/htx.c b/src/htx.c index bc2ecbdf3..a7623b6d9 100644 --- a/src/htx.c +++ b/src/htx.c @@ -502,6 +502,19 @@ struct htx_ret htx_xfer_blks(struct htx *dst, struct htx *src, uint32_t count, if (type == HTX_BLK_UNUSED) goto next; + /* Be sure to have enough space to xfer all headers in one + * time. If not while is empty, we report a parsing error + * on . + */ + if (mark >= HTX_BLK_EOH && (type == HTX_BLK_REQ_SL || type == HTX_BLK_RES_SL)) { + struct htx_sl *sl = htx_get_blk_ptr(src, blk); + + if (sl->hdrs_bytes != -1 && sl->hdrs_bytes > count) { + if (htx_is_empty(dst)) + src->flags |= HTX_FL_PARSING_ERROR; + break; + } + } sz = htx_get_blksz(blk); info = blk->info; diff --git a/src/mux_h2.c b/src/mux_h2.c index ddaa75180..55c7619c5 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -5406,8 +5406,11 @@ static size_t h2_rcv_buf(struct conn_stream *cs, struct buffer *buf, size_t coun htx_xfer_blks(buf_htx, h2s_htx, count, HTX_BLK_EOM); - if (h2s_htx->flags & HTX_FL_PARSING_ERROR) + if (h2s_htx->flags & HTX_FL_PARSING_ERROR) { buf_htx->flags |= HTX_FL_PARSING_ERROR; + if (htx_is_empty(buf_htx)) + cs->flags |= CS_FL_EOI; + } buf_htx->extra = (h2s_htx->extra ? (h2s_htx->data + h2s_htx->extra) : 0); htx_to_buf(buf_htx, buf);