]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/exec-invoke: use strnpcpy() where appropriate 39446/head
authorMike Yuan <me@yhndnzj.com>
Sat, 25 Oct 2025 17:18:34 +0000 (19:18 +0200)
committerMike Yuan <me@yhndnzj.com>
Sat, 25 Oct 2025 17:31:06 +0000 (19:31 +0200)
src/core/exec-invoke.c

index aaa9a0e8bd98b551b4858a4a4b5f08c4b3aadb13..2448baa125cdd3311e4ee331df87b7c585f33fc2 100644 (file)
@@ -77,6 +77,7 @@
 #include "stat-util.h"
 #include "string-table.h"
 #include "strv.h"
+#include "strxcpyx.h"
 #include "terminal-util.h"
 #include "user-util.h"
 #include "utmp-wtmp.h"
@@ -1504,7 +1505,7 @@ static void rename_process_from_path(const char *path) {
         size_t len = strlen(buf);
         char comm[TASK_COMM_LEN], *p = comm;
         *p++ = '(';
-        p = mempcpy(p, buf + LESS_BY(len, (size_t) (TASK_COMM_LEN - 3)), MIN(len, (size_t) (TASK_COMM_LEN - 3)));
+        strnpcpy(&p, TASK_COMM_LEN - 2, buf, len); /* strnpcpy() accounts for NUL byte internally */
         *p++ = ')';
         *p = '\0';