mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-05-04 20:46:11 +02:00
MINOR: mux-h2: Don't tests the start-line when sending HEADERS frame
When a HEADERS frame is sent, it is always when an HTX start-line block is found. Thus, in h2s_bck_make_req_headers() and h2s_frt_make_resp_headers() functions, it is useless to tests the start-line. Instead of being too defensive, we use BUG_ON() now because it must not happen and must be handled as a bug. This patch should fix the issue #1086.
This commit is contained in:
parent
3702f78cf9
commit
564981369b
26
src/mux_h2.c
26
src/mux_h2.c
@ -4943,10 +4943,7 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, struct htx *htx)
|
||||
break;
|
||||
|
||||
if (type == HTX_BLK_HDR) {
|
||||
if (!sl) {
|
||||
TRACE_ERROR("no start-line", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s);
|
||||
goto fail;
|
||||
}
|
||||
BUG_ON(!sl); /* The start-line mut be defined before any headers */
|
||||
if (unlikely(hdr >= sizeof(list)/sizeof(list[0]) - 1)) {
|
||||
TRACE_ERROR("too many headers", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s);
|
||||
goto fail;
|
||||
@ -4957,10 +4954,7 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, struct htx *htx)
|
||||
hdr++;
|
||||
}
|
||||
else if (type == HTX_BLK_RES_SL) {
|
||||
if (sl) {
|
||||
TRACE_PROTO("multiple start-lines", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s);
|
||||
goto fail;
|
||||
}
|
||||
BUG_ON(sl); /* Only one start-line expected */
|
||||
sl = htx_get_blk_ptr(htx, blk);
|
||||
h2s->status = sl->info.res.status;
|
||||
if (h2s->status == 204 || h2s->status == 304)
|
||||
@ -4993,6 +4987,9 @@ static size_t h2s_frt_make_resp_headers(struct h2s *h2s, struct htx *htx)
|
||||
}
|
||||
}
|
||||
|
||||
/* The start-line me be defined */
|
||||
BUG_ON(!sl);
|
||||
|
||||
/* marker for end of headers */
|
||||
list[hdr].n = ist("");
|
||||
|
||||
@ -5183,10 +5180,7 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
|
||||
break;
|
||||
|
||||
if (type == HTX_BLK_REQ_SL) {
|
||||
if (sl) {
|
||||
TRACE_ERROR("multiple start-lines", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s);
|
||||
goto fail;
|
||||
}
|
||||
BUG_ON(sl); /* Only one start-line expected */
|
||||
sl = htx_get_blk_ptr(htx, blk);
|
||||
meth = htx_sl_req_meth(sl);
|
||||
uri = htx_sl_req_uri(sl);
|
||||
@ -5198,10 +5192,7 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
|
||||
}
|
||||
}
|
||||
else if (type == HTX_BLK_HDR) {
|
||||
if (!sl) {
|
||||
TRACE_ERROR("no start-line", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s);
|
||||
goto fail;
|
||||
}
|
||||
BUG_ON(!sl); /* The start-line mut be defined before any headers */
|
||||
if (unlikely(hdr >= sizeof(list)/sizeof(list[0]) - 1)) {
|
||||
TRACE_ERROR("too many headers", H2_EV_TX_FRAME|H2_EV_TX_HDR|H2_EV_H2S_ERR, h2c->conn, h2s);
|
||||
goto fail;
|
||||
@ -5256,6 +5247,9 @@ static size_t h2s_bck_make_req_headers(struct h2s *h2s, struct htx *htx)
|
||||
}
|
||||
}
|
||||
|
||||
/* The start-line me be defined */
|
||||
BUG_ON(!sl);
|
||||
|
||||
/* Now add the server name to a header (if requested) */
|
||||
if ((h2c->flags & H2_CF_IS_BACK) && h2c->proxy->server_id_hdr_name) {
|
||||
struct server *srv = objt_server(h2c->conn->target);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user