From c4ea04c2b626446001d512c28e7ae1a5ccb4a1f0 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 23 Dec 2018 08:13:59 +0100 Subject: [PATCH] BUG/MINOR: mux-h2: make empty HEADERS frame return a connection error We were returning a stream error of type PROTOCOL_ERROR on empty HEADERS frames, but RFC7540#4.2 stipulates that we should instead return a connection error of type FRAME_SIZE_ERROR. This may be backported to 1.9 and 1.8 though it's unlikely to have any real life effect. --- src/mux_h2.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index 5ad32147ad..03c900da10 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -1824,9 +1824,10 @@ static struct h2s *h2c_frt_handle_headers(struct h2c *h2c, struct h2s *h2s) int error; if (!h2c->dfl) { - error = H2_ERR_PROTOCOL_ERROR; // empty headers frame! + /* RFC7540#4.2 */ + error = H2_ERR_FRAME_SIZE_ERROR; // empty headers frame! sess_log(h2c->conn->owner); - goto strm_err; + goto conn_err; } if (!b_size(&h2c->dbuf)) @@ -1914,9 +1915,10 @@ static struct h2s *h2c_bck_handle_headers(struct h2c *h2c, struct h2s *h2s) int error; if (!h2c->dfl) { - error = H2_ERR_PROTOCOL_ERROR; // empty headers frame! + /* RFC7540#4.2 */ + error = H2_ERR_FRAME_SIZE_ERROR; // empty headers frame! sess_log(h2c->conn->owner); - goto strm_err; + goto conn_err; } if (!b_size(&h2c->dbuf)) @@ -3103,9 +3105,9 @@ static int h2s_decode_headers(struct h2s *h2s) int try = 0; if (!h2c->dfl) { - h2s_error(h2s, H2_ERR_PROTOCOL_ERROR); // empty headers frame! - h2c->st0 = H2_CS_FRAME_E; - return 0; + /* RFC7540#4.2 */ + h2c_error(h2c, H2_ERR_FRAME_SIZE_ERROR); // empty headers frame! + goto fail; } if (b_data(&h2c->dbuf) < h2c->dfl && !b_full(&h2c->dbuf)) -- 2.47.3