From: Olivier Houchard Date: Wed, 29 Jul 2026 20:39:22 +0000 (+0200) Subject: BUG/MINOR: cli: use the current argument to parse the FD spec in "show fd" X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=355566f876bc1551b4fce28e89f5c763e9ea06a7;p=thirdparty%2Fhaproxy.git BUG/MINOR: cli: use the current argument to parse the FD spec in "show fd" Commit 1cb041a6e added filtering to show fd, which means the number of arguments can now change, however args[2] was still used from time to time. Fix this by using args|arg] instead when relevant. Note that before 3.4, there is only one instance of that, atoi(args[2]) should be atoi(args[arg]). That could lead to the wrong fd being used. This should be backported up to 2.8. --- diff --git a/src/cli.c b/src/cli.c index be5d02960..d6c2479b4 100644 --- a/src/cli.c +++ b/src/cli.c @@ -1870,7 +1870,7 @@ static int cli_parse_show_fd(char **args, char *payload, struct appctx *appctx, ctx->show_mask = CLI_SHOWFD_F_ANY; if (*args[arg]) { - c = strchr(args[2], '/'); + c = strchr(args[arg], '/'); if (c) { /* We allow the forms "/" and "/" where the missing * value is considered a wildcard. So the first form means @@ -1879,10 +1879,10 @@ static int cli_parse_show_fd(char **args, char *payload, struct appctx *appctx, * that the tgid is parsed but ignored for now - this code * will require changes once we split fd tables. */ - if (c == args[2]) { + if (c == args[arg]) { ctx->tgid = -1; } else { - ctx->tgid = atoi(args[2]); + ctx->tgid = atoi(args[arg]); if (ctx->tgid <= 0 || ctx->tgid > MAX_TGROUPS) return cli_err(appctx, "Invalid TGID.\n"); } @@ -1892,7 +1892,7 @@ static int cli_parse_show_fd(char **args, char *payload, struct appctx *appctx, ctx->show_one = 1; } } else { - ctx->fd = atoi(args[2]); + ctx->fd = atoi(args[arg]); ctx->show_one = 1; } }