]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mux-fcgi: Be sure to never set EOM flag on an empty HTX message
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 May 2022 07:24:52 +0000 (09:24 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 5 May 2022 07:24:55 +0000 (09:24 +0200)
This bug was already fixed at many places (stats, promex, lua) but the FCGI
multiplexer is also affected. When there is no content-length specified in
the response and when the END_REQUEST record is delayed, the response may be
truncated because an abort is erroneously detected. If the connection is not
closed because "keep-conn" option is set, the response is aborted at the end
of the server timeout.

This bug is a design issue with the HTX. It should be addressed. But it will
probably not be possible to backport them as far as 2.4. So, for now, the
only solution is to explicitly add an EOT block with the EOM flag in this
case.

This patch should fix the issue #1682. It must be backported as far as 2.4.

src/mux_fcgi.c

index b6ca2dba7c4930f86422a98c5d763f8bbef304a8..087e42b2f30cf8bf24129df75de3d59d336cb258 100644 (file)
@@ -3460,6 +3460,8 @@ static size_t fcgi_strm_parse_response(struct fcgi_strm *fstrm, struct buffer *b
                        if (!(h1m->flags & H1_MF_XFER_LEN) && fstrm->state != FCGI_SS_ERROR &&
                            (fstrm->flags & FCGI_SF_ES_RCVD) && b_data(&fstrm->rxbuf) == total) {
                                TRACE_DEVEL("end of data", FCGI_EV_RSP_DATA, fconn->conn, fstrm);
+                               if (htx_is_empty(htx) && !htx_add_endof(htx, HTX_BLK_EOT))
+                                       break;
                                htx->flags |= HTX_FL_EOM;
                                h1m->state = H1_MSG_DONE;
                                TRACE_USER("H1 response fully rcvd", FCGI_EV_RSP_DATA|FCGI_EV_RSP_EOM, fconn->conn, fstrm, htx);