From: Jérémie Galarneau Date: Thu, 12 Sep 2019 14:17:41 +0000 (-0400) Subject: lttng: fix: potential 0-length allocation in pid list parsing X-Git-Tag: v2.10.8~8 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=db548fb18a53ed7e3d56994241c565202ac61f1a;p=lttng-tools.git lttng: fix: potential 0-length allocation in pid list parsing Check that count is > 0 before allocating pid list. This would only happen after a prior error, but check it anyway. Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng/commands/track-untrack.c b/src/bin/lttng/commands/track-untrack.c index 6db4288c5..3073996a9 100644 --- a/src/bin/lttng/commands/track-untrack.c +++ b/src/bin/lttng/commands/track-untrack.c @@ -131,6 +131,11 @@ int parse_pid_string(const char *_pid_string, /* For next loop */ one_pid_str = strtok_r(NULL, ",", &iter); } + if (count == 0) { + ERR("Fatal error occurred when parsing pid string"); + retval = CMD_ERROR; + goto error; + } free(pid_string); /* Identity of delimiter has been lost in first pass. */