Fix: Crash on lttng list -j/-l/-p when no events are present
[lttng-tools.git] / src / bin / lttng / commands / list.c
index b436777d671b74bb2165d97eae9a5e6a1c6604e7..108f76065f907ad8b2dc9606b45b3d28dfdf2369 100644 (file)
@@ -25,6 +25,7 @@
 #include <assert.h>
 
 #include <common/mi-lttng.h>
+#include <lttng/constant.h>
 
 #include "../command.h"
 
@@ -106,7 +107,8 @@ static char *get_cmdline_by_pid(pid_t pid)
        int ret;
        FILE *fp = NULL;
        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");
@@ -407,7 +409,7 @@ static int list_agent_events(void)
        int i, size, ret = CMD_SUCCESS;
        struct lttng_domain domain;
        struct lttng_handle *handle;
-       struct lttng_event *event_list;
+       struct lttng_event *event_list = NULL;
        pid_t cur_pid = 0;
        char *cmdline = NULL;
        const char *agent_domain_str;
This page took 0.023841 seconds and 4 git commands to generate.