lttng: fix: potential 0-length allocation in pid list parsing
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 12 Sep 2019 14:17:41 +0000 (10:17 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 12 Sep 2019 14:18:33 +0000 (10:18 -0400)
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 <jeremie.galarneau@efficios.com>
src/bin/lttng/commands/track-untrack.c

index 6db4288c59ec471cf181a8429dfa424a0ff75762..3073996a9f6d19acfa257e87b1075959a9da3521 100644 (file)
@@ -131,6 +131,11 @@ int parse_pid_string(const char *_pid_string,
                /* For next loop */
                one_pid_str = strtok_r(NULL, ",", &iter);
        }
                /* 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. */
 
        free(pid_string);
        /* Identity of delimiter has been lost in first pass. */
This page took 0.035249 seconds and 4 git commands to generate.