diff --git a/src/h2.c b/src/h2.c index 731c21c478..536240a6dd 100644 --- a/src/h2.c +++ b/src/h2.c @@ -494,6 +494,10 @@ int h2_make_htx_request(struct http_hdr *list, struct htx *htx, unsigned int *ms goto fail; } + /* Check the number of blocks agains "tune.http.maxhdr" value before adding EOH block */ + if (htx_nbblks(htx) > global.tune.max_http_hdr) + goto fail; + /* now send the end of headers marker */ if (!htx_add_endof(htx, HTX_BLK_EOH)) goto fail; @@ -745,6 +749,10 @@ int h2_make_htx_response(struct http_hdr *list, struct htx *htx, unsigned int *m */ } + /* Check the number of blocks agains "tune.http.maxhdr" value before adding EOH block */ + if (htx_nbblks(htx) > global.tune.max_http_hdr) + goto fail; + /* now send the end of headers marker */ if (!htx_add_endof(htx, HTX_BLK_EOH)) goto fail; @@ -812,6 +820,10 @@ int h2_make_htx_trailers(struct http_hdr *list, struct htx *htx) goto fail; } + /* Check the number of blocks agains "tune.http.maxhdr" value before adding EOT block */ + if (htx_nbblks(htx) > global.tune.max_http_hdr) + goto fail; + if (!htx_add_endof(htx, HTX_BLK_EOT)) goto fail; diff --git a/src/mux_h2.c b/src/mux_h2.c index c1c7f1a699..970223c42b 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -5979,6 +5979,7 @@ static int h2c_dec_hdrs(struct h2c *h2c, struct buffer *rxbuf, uint32_t *flags, /* Trailers terminate a DATA sequence */ if (h2_make_htx_trailers(list, htx) <= 0) { TRACE_STATE("failed to append HTX trailers into rxbuf", H2_EV_RX_FRAME|H2_EV_RX_HDR|H2_EV_H2S_ERR, h2c->conn); + htx->flags |= HTX_FL_PARSING_ERROR; goto fail; } *flags |= H2_SF_ES_RCVD;