[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180119161103.15035-2-jolsa@kernel.org>
Date: Fri, 19 Jan 2018 17:11:02 +0100
From: Jiri Olsa <jolsa@...nel.org>
To: Arnaldo Carvalho de Melo <acme@...nel.org>
Cc: lkml <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Namhyung Kim <namhyung@...nel.org>,
David Ahern <dsahern@...il.com>,
Andi Kleen <ak@...ux.intel.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>
Subject: [PATCH 1/2] tools lib symbol: Use strtoul instead of hex2u64 in kallsyms__parse
Current kallsyms__parse uses hex2u64, which gives
no indication of error. Using strtoul to checkup
on failed attempt to parse the number and stop the
rest of the kallsyms__parse processing early.
Link: http://lkml.kernel.org/n/tip-djqwni3p6lgctf6o7xhhwpmw@git.kernel.org
Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
tools/lib/symbol/kallsyms.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/lib/symbol/kallsyms.c b/tools/lib/symbol/kallsyms.c
index 914cb8e3d40b..dd5bb1dfd2b6 100644
--- a/tools/lib/symbol/kallsyms.c
+++ b/tools/lib/symbol/kallsyms.c
@@ -29,6 +29,7 @@ int kallsyms__parse(const char *filename, void *arg,
int line_len, len;
char symbol_type;
char *symbol_name;
+ char *endptr;
line_len = getline(&line, &n, file);
if (line_len < 0 || !line)
@@ -36,9 +37,12 @@ int kallsyms__parse(const char *filename, void *arg,
line[--line_len] = '\0'; /* \n */
- len = hex2u64(line, &start);
+ start = strtoul(line, &endptr, 16);
+ if (line == endptr)
+ continue;
+
+ len = endptr - line + 1;
- len++;
if (len + 2 >= line_len)
continue;
--
2.13.6
Powered by blists - more mailing lists