]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: master/cli: properly trim the '@@' process name in error messages
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Apr 2025 15:47:23 +0000 (17:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Apr 2025 15:52:28 +0000 (17:52 +0200)
When '@@' alone is sent on the master CLI (no trailing LF), we get an
error that displays anything past these two characters in the buffer
since there's no room for a \0. Let's make sure to limit the length of
the process name in this case. No backport is needed since this was added
with 00c967fac4 ("MINOR: master/cli: support bidirectional communications
with workers").

src/cli.c

index 2b72df796414571ec79958d8c4eae019910c8dc5..66908bd4a20b96d3f7171f5a97330a18e06c6014 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2927,7 +2927,7 @@ int pcli_find_bidir_prefix(struct stream *s, struct channel *req, char **str, co
 
                target_pid = pcli_prefix_to_pid(pid_str + 1);
                if (target_pid == -1) {
-                       memprintf(errmsg, "Can't find the target PID matching the prefix '%s'\n", pid_str);
+                       memprintf(errmsg, "Can't find the target PID matching the prefix '%.*s'\n", (int)(p - pid_str), pid_str);
                        ret = -1;
                        goto leave;
                }