mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-12 18:16:58 +02:00
MINOR: mux-h1: Be prepare to fail when EOM is added during trailers parsing
When trailers are parsed, we must add the corrresponsing HTX block and then we must add the block end-of-message. But this last operation can failed because there is not enough space the HTX message. This case was left aside till now. Now, we stay in the state H1_MSG_TRAILERS with the warranty we will be able to restart at the right stage.
This commit is contained in:
parent
3218821b70
commit
1727648e10
10
src/mux_h1.c
10
src/mux_h1.c
@ -920,6 +920,7 @@ static size_t h1_process_data(struct h1s *h1s, struct h1m *h1m, struct htx *htx,
|
|||||||
if (!chksz) {
|
if (!chksz) {
|
||||||
if (!htx_add_endof(htx, HTX_BLK_EOD))
|
if (!htx_add_endof(htx, HTX_BLK_EOD))
|
||||||
goto end;
|
goto end;
|
||||||
|
h1s->flags |= H1S_F_HAVE_EOD;
|
||||||
h1m->state = H1_MSG_TRAILERS;
|
h1m->state = H1_MSG_TRAILERS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -956,6 +957,11 @@ static size_t h1_process_data(struct h1s *h1s, struct h1m *h1m, struct htx *htx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (h1m->state == H1_MSG_TRAILERS) {
|
if (h1m->state == H1_MSG_TRAILERS) {
|
||||||
|
/* Trailers were alread parsed, only the EOM
|
||||||
|
* need to be added */
|
||||||
|
if (h1s->flags & H1S_F_HAVE_TLR)
|
||||||
|
goto skip_tlr_parsing;
|
||||||
|
|
||||||
ret = h1_measure_trailers(buf, *ofs, *ofs + max);
|
ret = h1_measure_trailers(buf, *ofs, *ofs + max);
|
||||||
if (ret > data_space)
|
if (ret > data_space)
|
||||||
ret = (htx_is_empty(htx) ? -1 : 0);
|
ret = (htx_is_empty(htx) ? -1 : 0);
|
||||||
@ -974,12 +980,12 @@ static size_t h1_process_data(struct h1s *h1s, struct h1m *h1m, struct htx *htx,
|
|||||||
|
|
||||||
if (!htx_add_trailer(htx, ist2(b_peek(buf, *ofs), ret)))
|
if (!htx_add_trailer(htx, ist2(b_peek(buf, *ofs), ret)))
|
||||||
goto end;
|
goto end;
|
||||||
|
h1s->flags |= H1S_F_HAVE_TLR;
|
||||||
max -= ret;
|
max -= ret;
|
||||||
*ofs += ret;
|
*ofs += ret;
|
||||||
total += ret;
|
total += ret;
|
||||||
|
|
||||||
/* FIXME: if it fails here, this is a problem,
|
skip_tlr_parsing:
|
||||||
* because there is no way to return here. */
|
|
||||||
if (!htx_add_endof(htx, HTX_BLK_EOM))
|
if (!htx_add_endof(htx, HTX_BLK_EOM))
|
||||||
goto end;
|
goto end;
|
||||||
h1m->state = H1_MSG_DONE;
|
h1m->state = H1_MSG_DONE;
|
||||||
|
Loading…
Reference in New Issue
Block a user