X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=d7970a8b9ab2e0a2553ef5475d66fbc3ebd7d460;hb=4cd7fd8e6b1c3a7903107ee5eba761a0d15a4241;hp=a91d30757e1b9bdbd698a317aa93d286c778a038;hpb=d2243cc136eada1b871f4767b65c4d56c98ed6ad;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index a91d30757..d7970a8b9 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -23,6 +23,7 @@ #include #include +#include #include "../command.h" static int opt_userspace; @@ -107,7 +108,8 @@ static char *get_cmdline_by_pid(pid_t pid) int ret; FILE *fp; char *cmdline = NULL; - char path[20]; /* Can't go bigger than /proc/65535/cmdline */ + /* Can't go bigger than /proc/LTTNG_MAX_PID/cmdline */ + char path[sizeof("/proc//cmdline") + sizeof(LTTNG_MAX_PID_STR) - 1]; snprintf(path, sizeof(path), "/proc/%d/cmdline", pid); fp = fopen(path, "r"); @@ -116,7 +118,7 @@ static char *get_cmdline_by_pid(pid_t pid) } /* Caller must free() *cmdline */ - cmdline = malloc(PATH_MAX); + cmdline = zmalloc(PATH_MAX); if (!cmdline) { perror("malloc cmdline"); goto end;