]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: peers: fix partial message decoding
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 5 Dec 2023 08:21:38 +0000 (09:21 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 5 Dec 2023 08:28:53 +0000 (09:28 +0100)
peer_recv_msg() may return because the message is incomplete without
checking if a shutdown is pending for the SC. The function relies on
co_getblk() to detect shutdowns. However, the message length decoding may be
interrupted if the multi-bytes integer is incomplete. In this case, the SC
is not check for shutdowns.

When this happens, this leads to an appctx spinning loop.

This patch should fix the issue #2373. It must be backported to 2.8.

src/peers.c

index 23affa127b2aa1c31aa46fbede2b4bd4a37fa4da..5eefd1830e8f17606d004c6509e3cf07749b1149 100644 (file)
@@ -2455,7 +2455,7 @@ static inline int peer_recv_msg(struct appctx *appctx, char *msg_head, size_t ms
        return 1;
 
  incomplete:
-       if (reql < 0) {
+       if (reql < 0 || (sc->flags & (SC_FL_SHUT_DONE|SC_FL_SHUT_WANTED))) {
                /* there was an error or the message was truncated */
                appctx->st0 = PEER_SESS_ST_END;
                return -1;