]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-fcgi: Properly handle EOM flag on end-of-trailers HTX block
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 25 Mar 2024 07:02:06 +0000 (08:02 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 25 Mar 2024 10:06:41 +0000 (11:06 +0100)
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

index 617a9af9f34e4b6c13a648012d8a53ef74f3d511..cca3e93d72c63667db461e614e2352e7a8cba636 100644 (file)
@@ -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);