Hi,

Here are 12 independent BUG/MINOR fixes against current master (586d0eef7),
as git format-patch files. Patches 1 to 10 are attached here, and 11 and 12
follow in a reply, as my mail client limits the number of attachments. Each
one was reproduced on master before the fix and checked again after it; the
full reg-test suite gives the same result with and without the series (362
passed, 0 failed).

1. intops: decode_varint() accepted more than 10 bytes (shift by 67, UB)
and silently wrapped values >= 2^64. Every value encode_varint() produces
still round-trips.
2. mux-spop: AGENT-HELLO/DISCONNECT keys were matched by prefix
("max-frame-size-bogus" counted as max-frame-size).
3. mqtt: Will QoS 3, QoS or retain without Will, a 3.1.1 password without a
username, and 3.1.1 CONNACK codes > 5 were all accepted as valid.
4. mux-h2: atoi() in the tune.h2 keywords accepted "16384x", "x" (as 0,
which means unlimited) and empty values.
5. log: "sample 10-20,5-30:40" (a range enclosing another) passed the
overlap check.
6. base64: ubase64rev maps '=' to 63, so ub64dec decodes padding as data
("AB==" gives 00 1f ff). The cause is an off-by-one in
dev/base64/base64rev-gen.c, fixed too.
7. sample: ungrpc parsed compressed gRPC messages as plain protobuf.
8. net_helper: the eth.* converters did not skip 802.1ad (0x88a8) tags.
This patch touches lines next to my pending "accept an Ethernet header
ending with the protocol" patch; I can rebase whichever is applied second.
9. acme: "acme renew" without an argument released ckch_lock without
holding it.
10. activity: "show profiling tasks|memory <N>" read past the table when N
is larger than it (ASan heap-buffer-overflow; admin level only).
11. proto_tcp: a TCP_MD5SIG setsockopt() failure did not give the source
port back to the port range.
12. tools: on x86_64, the CBOR bin encoder wrote integer arguments in
little-endian order. This is 3.5-dev only, since c1abbb11f.

Backport notes are in each commit message.

Found by an LLM-assisted tool, verified manually.

Regards,
Martin Mirchev
From 6632dd64de372c50dc589a57ab010a590736e34b Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:34:00 +0800
Subject: [PATCH 01/12] BUG/MINOR: intops: reject varints that do not fit in 64
 bits in decode_varint()

decode_varint() accepts any number of continuation bytes. From the 11th
byte on, the shift count exceeds 63, which is undefined behaviour (UBSan:
"shift exponent 67 is too large for 64-bit type"), and a 10-byte varint
whose last byte is above 15 silently wraps: a value >= 2^64 is decoded
modulo 2^64. For example an SPOP agent sending the AGENT-HELLO
max-frame-size as f0 ff ff ff ff ff ff ff ff 7f has it decoded as
2314921131297212640 instead of being rejected.

encode_varint() never produces more than 10 bytes, the last one being at
most 15 for UINT64_MAX. Let's make the decoder fail when a byte would be
shifted by more than 63 bits, when bits would be shifted out, or when the
sum would wrap. Every value encode_varint() can produce still decodes to
itself (checked on edge values and 2M random values).

This should be backported to all stable versions.
---
 include/haproxy/intops.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/haproxy/intops.h b/include/haproxy/intops.h
index 08a9abc8b..00b44f501 100644
--- a/include/haproxy/intops.h
+++ b/include/haproxy/intops.h
@@ -650,9 +650,19 @@ static inline int decode_varint(char **buf, char *end, uint64_t *i)
 
 	r = 4;
 	do {
+		uint64_t v;
+
 		if (p >= (unsigned char *)end)
 			return -1;
-		*i += (uint64_t)*p << r;
+		/* the value must fit in 64 bits: no bit may be shifted out
+		 * and the sum must not wrap.
+		 */
+		if (r > 63)
+			return -1;
+		v = (uint64_t)*p << r;
+		if ((v >> r) != *p || *i + v < *i)
+			return -1;
+		*i += v;
 		r  += 7;
 	} while (*p++ >= 128);
 
-- 
2.50.1

From b57b5c404181ac6eaa9d6fd23a936807f47e8bdd Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:34:24 +0800
Subject: [PATCH 02/12] 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+).
---
 src/mux_spop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

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 *\/ */
-- 
2.50.1

From b48829d551ae70a8725a930de11b56d54c77613b Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:35:30 +0800
Subject: [PATCH 03/12] BUG/MINOR: mqtt: reject invalid CONNECT flags and MQTT
 3.1.1 CONNACK return codes

mqtt_is_valid() and the mqtt_field_value() converter accept several
messages the specifications forbid:

  - a CONNECT with the Will QoS set to 3. The only check rejected the
    case where both QoS bits are set without the Will flag, so neither
    "Will QoS 3 with Will" nor "Will QoS 1 or Will Retain without Will"
    was caught (MQTT 3.1.1 3.1.2.6/3.1.2.7, MQTT 5.0 3.1.2.6/3.1.2.7);
  - an MQTT 3.1.1 CONNECT with the Password flag but not the User Name
    flag (MQTT 3.1.1 3.1.2.9; MQTT 5.0 allows it, so only 3.1.1 is
    checked);
  - an MQTT 3.1.1 CONNACK with a return code above 5, e.g. 200 (MQTT
    3.1.1 3.2.2.3 only defines 0 to 5).

For example mqtt_is_valid returns 1 for a 3.1.1 CONNECT with flags 0x1c
or 0x40, and for a 3.1.1 CONNACK "20 02 00 c8". Reject these messages.

This should be backported to all stable versions.
---
 src/mqtt.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/mqtt.c b/src/mqtt.c
index 2cee38b5d..11a1eb474 100644
--- a/src/mqtt.c
+++ b/src/mqtt.c
@@ -738,8 +738,18 @@ static int mqtt_parse_connect(struct ist parser, struct mqtt_pkt *mpkt)
 	if (!isttest(parser) || (mpkt->data.connect.var_hdr.flags & MQTT_CONNECT_FL_RESERVED))
 		goto end;
 
-	/* if WILL flag must be set to have WILL_QOS flag or WILL_RETAIN set */
-	if ((mpkt->data.connect.var_hdr.flags & (MQTT_CONNECT_FL_WILL|MQTT_CONNECT_FL_WILL_QOS|MQTT_CONNECT_FL_WILL_RETAIN)) == MQTT_CONNECT_FL_WILL_QOS)
+	/* WILL flag must be set to have WILL_QOS flag or WILL_RETAIN set */
+	if (!(mpkt->data.connect.var_hdr.flags & MQTT_CONNECT_FL_WILL) &&
+	    (mpkt->data.connect.var_hdr.flags & (MQTT_CONNECT_FL_WILL_QOS|MQTT_CONNECT_FL_WILL_RETAIN)))
+	    goto end;
+
+	/* WILL_QOS must not be 3 */
+	if ((mpkt->data.connect.var_hdr.flags & MQTT_CONNECT_FL_WILL_QOS) == MQTT_CONNECT_FL_WILL_QOS)
+	    goto end;
+
+	/* in MQTT 3.1.1, PASSWORD flag requires the USERNAME flag */
+	if (mpkt->data.connect.var_hdr.protocol_version == MQTT_VERSION_3_1_1 &&
+	    (mpkt->data.connect.var_hdr.flags & (MQTT_CONNECT_FL_USERNAME|MQTT_CONNECT_FL_PASSWORD)) == MQTT_CONNECT_FL_PASSWORD)
 	    goto end;
 
 	/* read keepalive */
@@ -1025,8 +1035,12 @@ static int mqtt_parse_connack(struct ist parser, struct mqtt_pkt *mpkt)
 	if (!isttest(parser))
 		goto end;
 
-	/* we can leave here for MQTT 3.1.1 */
+	/* we can leave here for MQTT 3.1.1, where only return codes 0 to 5
+	 * are defined
+	 */
 	if (mpkt->data.connack.var_hdr.protocol_version == MQTT_VERSION_3_1_1) {
+		if (mpkt->data.connack.var_hdr.reason_code > 5)
+			goto end;
 		if ((orig_len - istlen(parser)) == mpkt->fixed_hdr.remaining_length)
 			ret = MQTT_VALID_MESSAGE;
 		goto end;
-- 
2.50.1

From db9b2e0bae206785732676d3750dfe9c81e4390b Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:36:59 +0800
Subject: [PATCH 04/12] BUG/MINOR: mux-h2: reject non-numeric values in the
 tune.h2 keywords

The tune.h2 numeric keywords are parsed with atoi(), so trailing garbage
and non-numeric values are silently accepted: "tune.h2.max-frame-size
16384x" sets 16384, "tune.h2.fe.max-total-streams x" and
"tune.h2.fe.glitches-threshold x" set 0, which means "unlimited" for both,
"tune.h2.header-table-size 8192k" sets 8192 and a missing glitches value
is taken as 0. The same applies to initial-window-size,
max-concurrent-streams (including its "rq-load" and "min" values) and the
max-{frames,rst}-at-once keywords, where a negative value is also silently
turned into a huge unsigned limit.

Parse these values with strtol() and reject empty values, trailing
characters and values that do not fit in an int, keeping the existing
range checks and error messages. max-{frames,rst}-at-once now also reject
negative values.

This should be backported to all stable versions.
---
 src/mux_h2.c | 46 +++++++++++++++++++++++++++++++---------------
 1 file changed, 31 insertions(+), 15 deletions(-)

diff --git a/src/mux_h2.c b/src/mux_h2.c
index 3ae71a065..56c03a1f9 100644
--- a/src/mux_h2.c
+++ b/src/mux_h2.c
@@ -9081,6 +9081,23 @@ static int h2_takeover(struct connection *conn, int orig_tid, int release)
 /* functions below are dedicated to the config parsers */
 /*******************************************************/
 
+/* Parses <arg> as a decimal integer into <*val>. Returns 0 on success, or -1
+ * if <arg> is empty, contains anything but an optional sign and digits, or
+ * does not fit in an int.
+ */
+static int h2_parse_int(const char *arg, int *val)
+{
+	char *end;
+	long v;
+
+	errno = 0;
+	v = strtol(arg, &end, 10);
+	if (!*arg || *end || errno || v < INT_MIN || v > INT_MAX)
+		return -1;
+	*val = v;
+	return 0;
+}
+
 /* config parser for global "tune.h2.{fe,be}.glitches-threshold" */
 static int h2_parse_glitches_threshold(char **args, int section_type, struct proxy *curpx,
 				       const struct proxy *defpx, const char *file, int line,
@@ -9094,8 +9111,7 @@ static int h2_parse_glitches_threshold(char **args, int section_type, struct pro
 	/* backend/frontend */
 	vptr = (args[0][8] == 'b') ? &h2_be_glitches_threshold : &h2_fe_glitches_threshold;
 
-	*vptr = atoi(args[1]);
-	if (*vptr < 0) {
+	if (h2_parse_int(args[1], vptr) || *vptr < 0) {
 		memprintf(err, "'%s' expects a positive numeric value.", args[0]);
 		return -1;
 	}
@@ -9110,8 +9126,8 @@ static int h2_parse_header_table_size(char **args, int section_type, struct prox
 	if (too_many_args(1, args, err, NULL))
 		return -1;
 
-	h2_settings_header_table_size = atoi(args[1]);
-	if (h2_settings_header_table_size < 4096 || h2_settings_header_table_size > 65536) {
+	if (h2_parse_int(args[1], &h2_settings_header_table_size) ||
+	    h2_settings_header_table_size < 4096 || h2_settings_header_table_size > 65536) {
 		memprintf(err, "'%s' expects a numeric value between 4096 and 65536.", args[0]);
 		return -1;
 	}
@@ -9133,8 +9149,7 @@ static int h2_parse_initial_window_size(char **args, int section_type, struct pr
 	       (args[0][8] == 'f') ? &h2_fe_settings_initial_window_size :
 	       &h2_settings_initial_window_size;
 
-	*vptr = atoi(args[1]);
-	if (*vptr < 0) {
+	if (h2_parse_int(args[1], vptr) || *vptr < 0) {
 		memprintf(err, "'%s' expects a positive numeric value.", args[0]);
 		return -1;
 	}
@@ -9183,8 +9198,7 @@ static int h2_parse_max_concurrent_streams(char **args, int section_type, struct
 	if (args[0][8] != 'f' && too_many_args(1, args, err, NULL))
 		return -1;
 
-	*vptr = atoi(args[1]);
-	if ((int)*vptr < 0) {
+	if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
 		memprintf(err, "'%s' expects a positive numeric value.", args[0]);
 		return -1;
 	}
@@ -9199,13 +9213,13 @@ static int h2_parse_max_concurrent_streams(char **args, int section_type, struct
 				h2_fe_max_rq_load = ~0;
 			else if (strcmp(args[arg + 1], "auto") == 0)
 				h2_fe_max_rq_load = 0;
-			else if (!*args[arg + 1] || (h2_fe_max_rq_load = atoi(args[arg + 1])) <= 0) {
+			else if (h2_parse_int(args[arg + 1], (int *)&h2_fe_max_rq_load) || (int)h2_fe_max_rq_load <= 0) {
 				memprintf(err, "'%s' expects a strictly positive run-queue length, or 'auto' or 'ignore'.", args[0]);
 				return -1;
 			}
 		}
 		else if (strcmp(args[arg], "min") == 0) {
-			if (!*args[arg + 1] || (h2_fe_min_concurrent_streams = atoi(args[arg + 1])) <= 0) {
+			if (h2_parse_int(args[arg + 1], (int *)&h2_fe_min_concurrent_streams) || (int)h2_fe_min_concurrent_streams <= 0) {
 				memprintf(err, "'%s' expects a strictly positive minimum number of streams'.", args[0]);
 				return -1;
 			}
@@ -9238,8 +9252,7 @@ static int h2_parse_max_total_streams(char **args, int section_type, struct prox
 	/* frontend only for now */
 	vptr = &h2_fe_max_total_streams;
 
-	*vptr = atoi(args[1]);
-	if ((int)*vptr < 0) {
+	if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
 		memprintf(err, "'%s' expects a positive numeric value.", args[0]);
 		return -1;
 	}
@@ -9266,7 +9279,10 @@ static int h2_parse_max_frames_at_once(char **args, int section_type, struct pro
 	if (too_many_args(1, args, err, NULL))
 		return -1;
 
-	*vptr = atoi(args[1]);
+	if (h2_parse_int(args[1], (int *)vptr) || (int)*vptr < 0) {
+		memprintf(err, "'%s' expects a positive numeric value.", args[0]);
+		return -1;
+	}
 	return 0;
 }
 
@@ -9278,8 +9294,8 @@ static int h2_parse_max_frame_size(char **args, int section_type, struct proxy *
 	if (too_many_args(1, args, err, NULL))
 		return -1;
 
-	h2_settings_max_frame_size = atoi(args[1]);
-	if (h2_settings_max_frame_size < 16384 || h2_settings_max_frame_size > 16777215) {
+	if (h2_parse_int(args[1], &h2_settings_max_frame_size) ||
+	    h2_settings_max_frame_size < 16384 || h2_settings_max_frame_size > 16777215) {
 		memprintf(err, "'%s' expects a numeric value between 16384 and 16777215.", args[0]);
 		return -1;
 	}
-- 
2.50.1

From 0f55e5371463b969b653c531ff1529f0033b93f9 Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:37:26 +0800
Subject: [PATCH 05/12] BUG/MINOR: log: also detect sampling ranges enclosing
 another one

smp_log_ranges_overlap() only reports an overlap when one of the bounds of
the new range falls inside an existing range, so a new range enclosing an
existing one is accepted: "sample 10-20,5-30:40" passes the configuration
check while "sample 10-20,15-25:40" is rejected with "ranges are
overlapping".

Use the usual interval test instead: two ranges overlap when each one
starts before the other ends.

This should be backported to all stable versions.
---
 src/log.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/log.c b/src/log.c
index 08681070b..7f25cc76b 100644
--- a/src/log.c
+++ b/src/log.c
@@ -1230,8 +1230,7 @@ int smp_log_ranges_overlap(struct smp_log_range *rgs, size_t sz,
 	size_t i;
 
 	for (i = 0; i < sz; i++) {
-		if ((low  >= rgs[i].low && low  <= rgs[i].high) ||
-		    (high >= rgs[i].low && high <= rgs[i].high)) {
+		if (low <= rgs[i].high && high >= rgs[i].low) {
 			memprintf(err, "ranges are overlapping");
 			return 1;
 		}
-- 
2.50.1

From ae342127c4471fb6b7f0b1c65f77d69bd01aa101 Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:38:52 +0800
Subject: [PATCH 06/12] BUG/MINOR: base64: do not decode '=' as data in
 base64urldec()

The ubase64rev table maps '=' to the value 63, i.e. the same as '_', so
base64urldec() (ub64dec converter, JWT) decodes padding characters as
data: "AB==" gives 00 1f ff instead of 00, "SGVsbG8=" gives "Hello?" and
a '=' in the middle of the input ("AB=C") is silently accepted.

The cause is an off-by-one in dev/base64/base64rev-gen.c which emits
base + B64PADV for '=' while the decoders subtract B64BASE + 1; base64rev
was apparently fixed by hand ('d') but ubase64rev, added later for the
url variant, kept the generated 'c'. With the generator fixed it produces
base64rev as found in the tree again.

base64urldec() has no notion of padding, so mark '=' as invalid in
ubase64rev, and strip one or two trailing '=' from inputs whose length is
a multiple of 4 since the padding is optional in base64url (RFC4648 #5).
Padded inputs now decode like their unpadded form, and '=' anywhere else
is rejected.

This should be backported to all stable versions.
---
 dev/base64/base64rev-gen.c |  2 +-
 src/base64.c               | 11 ++++++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/dev/base64/base64rev-gen.c b/dev/base64/base64rev-gen.c
index faffc8716..48105e082 100644
--- a/dev/base64/base64rev-gen.c
+++ b/dev/base64/base64rev-gen.c
@@ -47,7 +47,7 @@ int main() {
 		base64rev[c - min] = base+i+1;
 	}
 
-	base64rev['=' - min] = base + B64PADV;
+	base64rev['=' - min] = base + B64PADV + 1;
 
 	base64rev[max - min + 1] = '\0';
 
diff --git a/src/base64.c b/src/base64.c
index 57cb7d06a..16f8f97d0 100644
--- a/src/base64.c
+++ b/src/base64.c
@@ -26,7 +26,7 @@
 const char base64tab[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 const char base64rev[]="b###cXYZ[\\]^_`a###d###$%&'()*+,-./0123456789:;<=######>?@ABCDEFGHIJKLMNOPQRSTUVW";
 const char ubase64tab[65]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
-const char ubase64rev[]="b##XYZ[\\]^_`a###c###$%&'()*+,-./0123456789:;<=####c#>?@ABCDEFGHIJKLMNOPQRSTUVW";
+const char ubase64rev[]="b##XYZ[\\]^_`a#######$%&'()*+,-./0123456789:;<=####c#>?@ABCDEFGHIJKLMNOPQRSTUVW";
 
 /* Encodes <ilen> bytes from <in> to <out> for at most <olen> chars (including
  * the trailing zero). Returns the number of bytes written. No check is made
@@ -197,6 +197,15 @@ int base64urldec(const char *in, size_t ilen, char *out, size_t olen)
 	signed char b;
 	int convlen = 0, i = 0, pad = 0, padlen = 0;
 
+	/* the padding is optional in base64url (RFC4648 #5): strip it if
+	 * present so that the input is processed as unpadded.
+	 */
+	if (ilen && ilen % 4 == 0 && in[ilen - 1] == '=') {
+		ilen--;
+		if (in[ilen - 1] == '=')
+			ilen--;
+	}
+
 	switch (ilen % 4) {
 		case 0:
 			break;
-- 
2.50.1

From df95b7c7a944d44e99979212c22d8d51fe7b9767 Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:39:28 +0800
Subject: [PATCH 07/12] BUG/MINOR: sample: do not parse compressed gRPC
 messages in ungrpc

sample_conv_ungrpc() skips the 5-byte gRPC message header without looking
at its Compressed-Flag byte, so a message whose payload is compressed
(flag 1) is handed to the protobuf parser as if it were plain protobuf,
and so is a message with an invalid flag value. A request body
"01 00 00 00 02 08 2a" (compressed flag, 2-byte payload) returns 42 from
"req.body,ungrpc(1,uint32)", exactly as the uncompressed one does, while
the real field value would only appear after decompression.

Skip compressed messages, as their payload cannot be parsed, and stop on
a flag other than 0 or 1 since the gRPC framing is then invalid.

This should be backported to all stable versions.
---
 src/sample.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/sample.c b/src/sample.c
index eddef4be3..a47066d99 100644
--- a/src/sample.c
+++ b/src/sample.c
@@ -4480,6 +4480,12 @@ static int sample_conv_ungrpc(const struct arg *arg_p, struct sample *smp, void
 	while (grpc_left > GRPC_MSG_HEADER_SZ) {
 		size_t grpc_msg_len, left;
 		unsigned char *msg_end;
+		unsigned char compressed;
+
+		/* the Compressed-Flag may only be 0 or 1 */
+		compressed = *pos;
+		if (compressed > 1)
+			return 0;
 
 		grpc_msg_len = left = ntohl(read_u32(pos + GRPC_MSG_COMPRESS_FLAG_SZ));
 
@@ -4498,7 +4504,8 @@ static int sample_conv_ungrpc(const struct arg *arg_p, struct sample *smp, void
 		 */
 		msg_end = pos + grpc_msg_len;
 
-		if (protobuf_field_lookup(arg_p, smp, &pos, &left))
+		/* a compressed message cannot be parsed as protobuf, skip it */
+		if (!compressed && protobuf_field_lookup(arg_p, smp, &pos, &left))
 			return 1;
 
 		pos = msg_end;
-- 
2.50.1

From 5639077694b28bc10aeba89fb7f72eab2c26d06a Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:39:56 +0800
Subject: [PATCH 08/12] BUG/MINOR: net_helper: also skip 802.1ad VLAN tags in
 the eth.* converters

The eth.data, eth.hdr, eth.proto and eth.vlan converters only recognize
VLAN tags with the 802.1Q TPID 0x8100. The outer tag of a double-tagged
(QinQ) frame uses the 802.1ad TPID 0x88a8, so for such a frame eth.proto
returns 34984 (0x88a8) instead of the EtherType that follows the tags, as
documented ("found in a Ethernet header after any optional VLAN"), and
eth.data/eth.hdr/eth.vlan stop at the outer tag.

Treat 0x88a8 as a VLAN TPID too.

This should be backported to 3.4.
---
 src/net_helper.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/net_helper.c b/src/net_helper.c
index 4cfa457cb..89fdb0b5b 100644
--- a/src/net_helper.c
+++ b/src/net_helper.c
@@ -15,6 +15,14 @@
 /* Converters used to process Ethernet frame headers */
 /*****************************************************/
 
+/* returns non-zero if <tpid> is the TPID of a VLAN tag: 802.1Q (0x8100) or
+ * 802.1ad (0x88a8, the outer tag of a double-tagged frame).
+ */
+static inline int eth_is_vlan_tpid(ushort tpid)
+{
+	return tpid == 0x8100 || tpid == 0x88a8;
+}
+
 /* returns only the data part of an input ethernet frame header, skipping any
  * possible VLAN header. This is typically used to return the beginning of the
  * IP packet.
@@ -24,7 +32,7 @@ static int sample_conv_eth_data(const struct arg *arg_p, struct sample *smp, voi
 	size_t idx;
 
 	for (idx = 12; idx + 2 < smp->data.u.str.data; idx += 4) {
-		if (read_n16(smp->data.u.str.area + idx) != 0x8100) {
+		if (!eth_is_vlan_tpid(read_n16(smp->data.u.str.area + idx))) {
 			if (smp->data.u.str.size)
 				smp->data.u.str.size -= idx + 2;
 			smp->data.u.str.area += idx + 2;
@@ -55,7 +63,7 @@ static int sample_conv_eth_hdr(const struct arg *arg_p, struct sample *smp, void
 	size_t idx;
 
 	for (idx = 12; idx + 2 < smp->data.u.str.data; idx += 4) {
-		if (read_n16(smp->data.u.str.area + idx) != 0x8100) {
+		if (!eth_is_vlan_tpid(read_n16(smp->data.u.str.area + idx))) {
 			smp->data.u.str.data = idx + 2;
 			return 1;
 		}
@@ -74,7 +82,7 @@ static int sample_conv_eth_proto(const struct arg *arg_p, struct sample *smp, vo
 
 	for (idx = 12; idx + 2 < smp->data.u.str.data; idx += 4) {
 		proto = read_n16(smp->data.u.str.area + idx);
-		if (proto != 0x8100) {
+		if (!eth_is_vlan_tpid(proto)) {
 			smp->data.u.sint = proto;
 			smp->data.type = SMP_T_SINT;
 			smp->flags &= ~SMP_F_CONST;
@@ -108,7 +116,7 @@ static int sample_conv_eth_vlan(const struct arg *arg_p, struct sample *smp, voi
 	size_t idx;
 
 	for (idx = 12; idx + 2 < smp->data.u.str.data; idx += 4) {
-		if (read_n16(smp->data.u.str.area + idx) != 0x8100) {
+		if (!eth_is_vlan_tpid(read_n16(smp->data.u.str.area + idx))) {
 			smp->data.u.sint = vlan;
 			smp->data.type = SMP_T_SINT;
 			smp->flags &= ~SMP_F_CONST;
-- 
2.50.1

From 8d5f531f61e180375a30a45393134bcef3844b37 Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:40:34 +0800
Subject: [PATCH 09/12] BUG/MINOR: acme: do not unlock ckch_lock when "acme
 renew" lacks its argument

cli_acme_renew_parse() jumps to its error label when the certificate name
is missing, before HA_SPIN_TRYLOCK() is attempted, and that label
unconditionally releases ckch_lock. "acme renew" without argument thus
unlocks a lock it does not hold; if another thread holds it at that moment
(e.g. during a "set ssl cert" transaction), the lock is released under its
feet.

Return the error directly instead, as is already done for the lock
failure.

This should be backported to 3.2.
---
 src/acme.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/acme.c b/src/acme.c
index ecf536744..7280c21fa 100644
--- a/src/acme.c
+++ b/src/acme.c
@@ -3549,10 +3549,8 @@ static int cli_acme_renew_parse(char **args, char *payload, struct appctx *appct
 	if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
 		return 1;
 
-	if (!*args[2]) {
-		memprintf(&errmsg, ": not enough parameters\n");
-		goto err;
-	}
+	if (!*args[2])
+		return cli_err(appctx, ": not enough parameters\n");
 
 	if (HA_SPIN_TRYLOCK(CKCH_LOCK, &ckch_lock))
 		return cli_err(appctx, "Can't update: operations on certificates are currently locked!\n");
-- 
2.50.1

From 2df6a5662cbdb3fcd8e8e6fd459c6a4548fd1309 Mon Sep 17 00:00:00 2001
From: Martin Mirchev <[email protected]>
Date: Wed, 18 Nov 2026 20:41:32 +0800
Subject: [PATCH 10/12] BUG/MINOR: activity: limit "show profiling" output
 lines to the table size

"show profiling tasks <N>" and "show profiling memory <N>" use <N> as the
upper bound of the loop walking the temporary copy of the tasks or memory
profiling table, without capping it to the table size. With N above the
number of entries, the loop reads past the end of the allocation; with
ASan, "show profiling tasks 100000" reports a heap-buffer-overflow READ of
size 8 right after the 16384-byte tmp_activity area in
cli_io_handler_show_profiling(), with a default build it reads whatever
follows. The command requires the admin level, which is why it is only a
minor issue.

Cap the number of lines to the size of the table being dumped.

This should be backported to all stable versions.
---
 src/activity.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/activity.c b/src/activity.c
index 4357c35ad..1ef477178 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -1171,7 +1171,7 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
 			      (prof_task_stop_ns ? now_ns - prof_task_stop_ns : 0) / 1000000000.0);
 
 	max_lines = ctx->maxcnt;
-	if (!max_lines)
+	if (!max_lines || max_lines > SCHED_ACT_HASH_BUCKETS)
 		max_lines = SCHED_ACT_HASH_BUCKETS;
 
 	dumped = 0;
@@ -1295,7 +1295,7 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
 			      (prof_mem_stop_ns ? now_ns - prof_mem_stop_ns : 0) / 1000000000.0);
 
 	max_lines = ctx->maxcnt;
-	if (!max_lines)
+	if (!max_lines || max_lines > MEMPROF_HASH_BUCKETS + 1)
 		max_lines = MEMPROF_HASH_BUCKETS + 1;
 
 	dumped = 0;
-- 
2.50.1

Reply via email to