[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1406415268-8429-1-git-send-email-rickard_strandqvist@spectrumdigital.se>
Date: Sun, 27 Jul 2014 00:54:28 +0200
From: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
To: Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Paul Mackerras <paulus@...ba.org>
Cc: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>,
Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung.kim@....com>,
Jiri Olsa <jolsa@...hat.com>,
Stephane Eranian <eranian@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
Vince Weaver <vincent.weaver@...ne.edu>,
Michael Ellerman <michael@...erman.id.au>,
linux-kernel@...r.kernel.org
Subject: [PATCH] tools: perf: util: parse-events.c: Cleaning up missing null-terminate in conjunction with strncpy
Ensures that the string is null-terminate in connection with the
use of strncpy. And removed unnecessary magic numbers.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@...ctrumdigital.se>
---
tools/perf/util/parse-events.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 1e15df1..e2cd8c4 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -210,8 +210,12 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
}
strncpy(path->system, sys_dirent.d_name,
MAX_EVENT_LENGTH);
+ path->system[MAX_EVENT_LENGTH - 1] = '\0';
+
strncpy(path->name, evt_dirent.d_name,
MAX_EVENT_LENGTH);
+ path->name[MAX_EVENT_LENGTH - 1] = '\0';
+
return path;
}
}
@@ -1216,8 +1220,10 @@ static void print_symbol_events(const char *event_glob, unsigned type,
if (strlen(syms->alias))
snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
- else
+ else {
strncpy(name, syms->symbol, MAX_NAME_LEN);
+ name[MAX_NAME_LEN - 1] = '\0';
+ }
printf(" %-50s [%s]\n", name, event_type_descriptors[type]);
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists