X-Git-Url: http://git.lttng.org./?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=bcf2f0a5f0b44e5bc7c4cd36746d94c9adc33d92;hb=3388f253ecdf6ce0d24c4ba677cf04ab07cce666;hp=6d75104811f8cf8bfdb15fc8280b9ef39b957579;hpb=8639413fbcccd910c4a3eff07bba818f59a99add;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index 6d7510481..bcf2f0a5f 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -24,6 +24,7 @@ #include #include +#include #include "../command.h" @@ -116,7 +117,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"); @@ -416,8 +418,8 @@ 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_handle *handle = NULL; + struct lttng_event *event_list = NULL; pid_t cur_pid = 0; char *cmdline = NULL; const char *agent_domain_str; @@ -427,6 +429,10 @@ static int list_agent_events(void) domain.type = LTTNG_DOMAIN_JUL; } else if (opt_log4j) { domain.type = LTTNG_DOMAIN_LOG4J; + } else { + ERR("Invalid agent domain selected."); + ret = CMD_ERROR; + goto error; } agent_domain_str = get_domain_str(domain.type); @@ -495,7 +501,7 @@ static int list_ust_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;