From 56c4b29ff1e7df05201fa736aa3f35307443f73b Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Mon, 25 Mar 2024 08:02:06 +0100 Subject: [PATCH] BUG/MEDIUM: mux-fcgi: Properly handle EOM flag on end-of-trailers HTX block Trailers are skipped by the FCGI multiplexer. However empty chunked messages are not properly handled. It may be a chunked H1 request with no payload or a H2/H3 POST request with no payload. In that caes, the EOT HTX block is just ignored. The issue is that the EOM flag is thus ignored too. It means no empty STDIN record is sent to mark the end of the request to the server. To fix the issue, when a EOT htx block is found and it is the last HTX block of the message (and it should be), the EOM flag is tested. If it is found, an empty STDIN record is emitted. This patch should fix the issue #2499. It must be backported as far as 2.4. --- src/mux_fcgi.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 617a9af9f..cca3e93d7 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -4043,6 +4043,15 @@ static size_t fcgi_snd_buf(struct stconn *sc, struct buffer *buf, size_t count, } break; + case HTX_BLK_EOT: + if (htx_is_unique_blk(htx, blk) && (htx->flags & HTX_FL_EOM)) { + TRACE_PROTO("sending FCGI STDIN record", FCGI_EV_TX_RECORD|FCGI_EV_TX_STDIN, fconn->conn, fstrm, htx); + ret = fcgi_strm_send_empty_stdin(fconn, fstrm); + if (!ret) + goto done; + } + __fallthrough; + default: remove_blk: htx_remove_blk(htx, blk);