From: Alejandro Colomar Date: Fri, 6 Jun 2025 13:45:15 +0000 (+0200) Subject: lib/get_pid.c: Use PATH_MAX instead of a magic number X-Git-Tag: 4.18.0-rc1~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f7b9ac5b7b6d5f47900ea23d04b63d994306d6bd;p=thirdparty%2Fshadow.git lib/get_pid.c: Use PATH_MAX instead of a magic number Acked-by: Lukas Slebodnik Signed-off-by: Alejandro Colomar --- diff --git a/lib/get_pid.c b/lib/get_pid.c index f4d31cfda..4a0c2efac 100644 --- a/lib/get_pid.c +++ b/lib/get_pid.c @@ -5,15 +5,14 @@ #include -#ident "$Id$" - -#include "prototypes.h" -#include "defines.h" +#include +#include #include #include -#include #include "atoi/getnum.h" +#include "defines.h" +#include "prototypes.h" #include "string/sprintf/snprintf.h" @@ -52,13 +51,12 @@ int get_pidfd_from_fd(const char *pidfdstr) int open_pidfd(const char *pidstr) { int proc_dir_fd; - char proc_dir_name[32]; + char proc_dir_name[PATH_MAX]; pid_t target; if (get_pid(pidstr, &target) == -1) return -ENOENT; - /* max string length is 6 + 10 + 1 + 1 = 18, allocate 32 bytes */ if (SNPRINTF(proc_dir_name, "/proc/%u/", target) == -1) { fprintf(stderr, "snprintf of proc path failed for %u: %s\n", target, strerror(errno));