From ab0c97139f29e8f2498da03e0ae6339402a08f12 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 16 Oct 2025 08:27:44 +0200 Subject: [PATCH] BUG/MEDIUM: pools: fix crash on filtered "show pools" output The truncation of pools output that was adressed in commit 982805e6a3 ("BUG/MINOR: pools: Fix the dump of pools info to deal with buffers limitations") required to split the pools filling from dumping. However there is a problem when a limit is passed that is lower than the number of pools or if a pool name is specified or if pool caches are disabled, because in this case the number of filled slots will be lower than the initially allocated one, and empty entries will be visited either by the sort functions when filling the entries if "byxxx" is specified, or by the dump function after the last entry, but none of these functions was expecting to be passed a NULL entry. Let's just re-adjust nbpools to match the number of filled entries at the end. Anyway the totals are calculated on the number of dumped entries. This must be backported to 3.2 since the fix above was backported there as well. --- src/pool.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/pool.c b/src/pool.c index bcfb4fdc7..594195d10 100644 --- a/src/pool.c +++ b/src/pool.c @@ -1374,6 +1374,9 @@ static int get_show_pools_info(struct show_pools_ctx *ctx) n++; } + /* adjust the number of entries to be dumped */ + ctx->nbpools = n; + if (by_what == 1) /* sort by name */ qsort(ctx->pool_info, ctx->nbpools, sizeof(*ctx->pool_info), cmp_dump_pools_name); else if (by_what == 2) /* sort by item size */