Skip to contentSkip to conversation

perf trace: Fix off by one string allocation problem

tip:perf/core tip-bot for Arnaldo Carvalho de Melo 1 participant 1 message Aug 22, 2017 perf events

lore
Share & tools
lore
#0 lore raw
Commit-ID:  d6d4fc6fefda26a88eb99d30e87a8834c59c144a
Gitweb:     http://git.kernel.org/tip/d6d4fc6fefda26a88eb99d30e87a8834c59c144a
Author:     Arnaldo Carvalho de Melo <[email protected]>
AuthorDate: Thu, 17 Aug 2017 15:12:55 -0300
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 17 Aug 2017 16:39:14 -0300

perf trace: Fix off by one string allocation problem

We need to consider the null terminator, oops, fix it.

Cc Adrian Hunter <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Wang Nan <[email protected]>
Fixes 017037ff3d0b ("perf trace: Allow specifying list of syscalls and events in -e/--expr/--event")
---
 tools/perf/builtin-trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-trace.c +1 -1
index de02413..9190583 100644
@@ -2806,7 +2806,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str,
 	struct trace *trace = (struct trace *)opt->value;
 	const char *s = str;
 	char *sep = NULL, *lists[2] = { NULL, NULL, };
-	int len = strlen(str), err = -1, list;
+	int len = strlen(str) + 1, err = -1, list;
 	char *strace_groups_dir = system_path(STRACE_GROUPS_DIR);
 	char group_name[PATH_MAX];