summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/parse-events.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2012-12-08 15:18:41 +0100
committerIngo Molnar <mingo@kernel.org>2012-12-08 15:18:41 +0100
commitadc1ef1e37358d3c17d1a74a58b2e104fc0bda15 (patch)
tree6f43107a76ed87f2b817594d2d62246ab82cfba6 /tools/perf/util/parse-events.c
parent84e53ff77cb1e005f49966cd6789109d84acc9e2 (diff)
parent07ac002f2fcc74c5be47b656d9201d5de84dc53d (diff)
downloadlinux-adc1ef1e37358d3c17d1a74a58b2e104fc0bda15.tar.gz
linux-adc1ef1e37358d3c17d1a74a58b2e104fc0bda15.tar.bz2
linux-adc1ef1e37358d3c17d1a74a58b2e104fc0bda15.zip
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo: - UAPI fixes, from David Howels - Separate perf tests into multiple objects, one per test, from Jiri Olsa. - Fixes to /proc/pid/maps parsing, preparatory to supporting data maps, from Namhyung Kim - Fix compile error for non-NEWT builds, from Namhyung Kim - Implement ui_progress for GTK, from Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/perf/util/parse-events.c')
-rw-r--r--tools/perf/util/parse-events.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index c0b785b50849..020323af3364 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -722,6 +722,27 @@ static int get_event_modifier(struct event_modifier *mod, char *str,
return 0;
}
+/*
+ * Basic modifier sanity check to validate it contains only one
+ * instance of any modifier (apart from 'p') present.
+ */
+static int check_modifier(char *str)
+{
+ char *p = str;
+
+ /* The sizeof includes 0 byte as well. */
+ if (strlen(str) > (sizeof("ukhGHppp") - 1))
+ return -1;
+
+ while (*p) {
+ if (*p != 'p' && strchr(p + 1, *p))
+ return -1;
+ p++;
+ }
+
+ return 0;
+}
+
int parse_events__modifier_event(struct list_head *list, char *str, bool add)
{
struct perf_evsel *evsel;
@@ -730,6 +751,9 @@ int parse_events__modifier_event(struct list_head *list, char *str, bool add)
if (str == NULL)
return 0;
+ if (check_modifier(str))
+ return -EINVAL;
+
if (!add && get_event_modifier(&mod, str, NULL))
return -EINVAL;