From 70627d3690995485c51bff33d8cfa8ed5b6af555 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 14 Oct 2025 18:46:33 +0200 Subject: [PATCH] MEDIUM: peers: Forbid value greater than 65535 The "shard" server parameter is now limited to a 2-bytes integer, so lower than 65535. The idea is to limit its size and save some bytes in the stksess structure. --- doc/configuration.txt | 6 +++--- src/cfgparse.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index 7eaaf3419..a6b3e2096 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -30181,11 +30181,11 @@ server [/] [param*] server haproxy3 10.2.0.1:1024 shards - In some configurations, one would like to distribute the stick-table contents to some peers in place of sending all the stick-table contents to each peer - declared in the "peers" section. In such cases, "shards" specifies the - number of peer involved in this stick-table contents distribution. + declared in the "peers" section. In such cases, "shards" specifies the number + of peer involved in this stick-table contents distribution. It must be an + integer value between 1 and 65535. See also "shard" server parameter. table type {ip | integer | string [len ] | binary [len ]} diff --git a/src/cfgparse.c b/src/cfgparse.c index f411d6ea1..56375c194 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -1010,8 +1010,8 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm) goto out; } - if (!curpeers->nb_shards) { - ha_alert("parsing [%s:%d] : '%s' : expects a strictly positive integer argument\n", + if (!curpeers->nb_shards || curpeers->nb_shards > 65535) { + ha_alert("parsing [%s:%d] : '%s' : expects a integer argument between 1 and 65535\n", file, linenum, args[0]); err_code |= ERR_FATAL; goto out; -- 2.47.3