X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng%2Fcommands%2Flist.c;h=cc776dd427dcc5e30bce41d430f26c1a6ac77fcd;hb=44c1a903e17ad14d5ba1cd07585a7a2415eac78a;hp=b436777d671b74bb2165d97eae9a5e6a1c6604e7;hpb=2fa605f7de6b95f50fc864072bc1445c61eb2c79;p=lttng-tools.git diff --git a/src/bin/lttng/commands/list.c b/src/bin/lttng/commands/list.c index b436777d6..cc776dd42 100644 --- a/src/bin/lttng/commands/list.c +++ b/src/bin/lttng/commands/list.c @@ -25,6 +25,7 @@ #include #include +#include #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"); @@ -406,8 +408,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; @@ -419,6 +421,10 @@ static int list_agent_events(void) domain.type = LTTNG_DOMAIN_LOG4J; } else if (opt_python) { domain.type = LTTNG_DOMAIN_PYTHON; + } else { + ERR("Invalid agent domain selected."); + ret = CMD_ERROR; + goto error; } agent_domain_str = get_domain_str(domain.type);