]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: cli: use the current argument to parse the FD spec in "show fd"
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 29 Jul 2026 20:39:22 +0000 (22:39 +0200)
committerOlivier Houchard <cognet@ci0.org>
Wed, 29 Jul 2026 20:52:29 +0000 (22:52 +0200)
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.

src/cli.c

index be5d02960d3984214a6e765c1c0050555c476672..d6c2479b494888d4bd7af9fac21bd09f24170938 100644 (file)
--- 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 "<tgid>/" and "/<fd>" 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;
                }
        }