From: Martin Mirchev Date: Wed, 18 Nov 2026 12:34:24 +0000 (+0800) Subject: BUG/MINOR: mux-spop: match the AGENT-HELLO and AGENT-DISCONNECT keys exactly X-Git-Url: https://git.kaiwu.me/http/%22../static/gitweb.js?a=commitdiff_plain;h=d77d76a440459e9d9a45e728257487d9a51ca59d;p=haproxy.git BUG/MINOR: mux-spop: match the AGENT-HELLO and AGENT-DISCONNECT keys exactly The K/V keys of the AGENT-HELLO and AGENT-DISCONNECT frames are compared with "sz >= strlen(KEY) && !memcmp(str, KEY, strlen(KEY))", which is a prefix match: an agent sending "max-frame-size-bogus" (or "versionX", "capabilitiesX", "status-codeX") has the item treated as the mandatory one. With an invalid value under "max-frame-size-bogus", haproxy closes the connection with "max-frame-size too big or too small", exactly as for the real key, while a key sharing no prefix is ignored as it should be. Compare the whole key instead. The commented-out "message" check is updated the same way. This should be backported to all versions with mux-spop (3.1+). --- diff --git a/src/mux_spop.c b/src/mux_spop.c index 06daaa7b9..daf5ace27 100644 --- a/src/mux_spop.c +++ b/src/mux_spop.c @@ -1689,7 +1689,7 @@ static int spop_conn_handle_hello(struct spop_conn *spop_conn) } /* Check "version" K/V item */ - if (sz >= strlen(SPOP_VERSION_KEY) && !memcmp(str, SPOP_VERSION_KEY, strlen(SPOP_VERSION_KEY))) { + if (sz == strlen(SPOP_VERSION_KEY) && !memcmp(str, SPOP_VERSION_KEY, sz)) { int type = *p++; /* The value must be a string */ @@ -1713,7 +1713,7 @@ static int spop_conn_handle_hello(struct spop_conn *spop_conn) } } /* Check "max-frame-size" K/V item */ - else if (sz >= strlen(SPOP_MAX_FRAME_SIZE_KEY) && !memcmp(str, SPOP_MAX_FRAME_SIZE_KEY, SPOP_SLEN(SPOP_MAX_FRAME_SIZE_KEY))) { + else if (sz == strlen(SPOP_MAX_FRAME_SIZE_KEY) && !memcmp(str, SPOP_MAX_FRAME_SIZE_KEY, sz)) { int type = *p++; /* The value must be integer */ @@ -1735,7 +1735,7 @@ static int spop_conn_handle_hello(struct spop_conn *spop_conn) max_frame_size = sz; } /* Check "capabilities" K/V item */ - else if (sz >= strlen(SPOP_CAPABILITIES_KEY) && !memcmp(str, SPOP_CAPABILITIES_KEY, SPOP_SLEN(SPOP_CAPABILITIES_KEY))) { + else if (sz == strlen(SPOP_CAPABILITIES_KEY) && !memcmp(str, SPOP_CAPABILITIES_KEY, sz)) { int type = *p++; /* The value must be a string */ @@ -1854,7 +1854,7 @@ static int spop_conn_handle_disconnect(struct spop_conn *spop_conn) } /* Check "status-code" K/V item */ - if (sz >= strlen(SPOP_STATUS_CODE_KEY) && !memcmp(str, SPOP_STATUS_CODE_KEY, strlen(SPOP_STATUS_CODE_KEY))) { + if (sz == strlen(SPOP_STATUS_CODE_KEY) && !memcmp(str, SPOP_STATUS_CODE_KEY, sz)) { int type = *p++; /* The value must be an integer */ @@ -1873,7 +1873,7 @@ static int spop_conn_handle_disconnect(struct spop_conn *spop_conn) } // TODO: for now skip the reason /* /\* Check "message" K/V item *\/ */ - /* else if (sz >= strlen(SPOP_MSG_KEY) && !memcmp(str, SPOP_MSG_KEY, strlen(SPOP_MSG_KEY))) { */ + /* else if (sz == strlen(SPOP_MSG_KEY) && !memcmp(str, SPOP_MSG_KEY, sz)) { */ /* int type = *p++; */ /* /\* The value must be a string *\/ */