[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101217131206.24123.87394.stgit@ltc236.sdl.hitachi.co.jp>
Date: Fri, 17 Dec 2010 22:12:06 +0900
From: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
To: Arnaldo Carvalho de Melo <acme@...hat.com>,
Ingo Molnar <mingo@...e.hu>
Cc: Steven Rostedt <rostedt@...dmis.org>,
Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
linux-kernel@...r.kernel.org, 2nddept-manager@....hitachi.co.jp,
Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Paul Mackerras <paulus@...ba.org>, Ingo Molnar <mingo@...e.hu>,
Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
linux-kernel@...r.kernel.org
Subject: [PATCH -tip 2/4] [BUGFIX]perf: Fix strlist__parse_list to handle
const string
Fix strlist__parse_list to handle const string. Without
this patch, strlist__parse_list() causes SEGV when
caller passes a constant string.
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc: linux-kernel@...r.kernel.org
---
tools/perf/util/strlist.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/perf/util/strlist.c b/tools/perf/util/strlist.c
index 6783a20..caa7884 100644
--- a/tools/perf/util/strlist.c
+++ b/tools/perf/util/strlist.c
@@ -136,13 +136,19 @@ static int strlist__parse_list_entry(struct strlist *self, const char *s)
int strlist__parse_list(struct strlist *self, const char *s)
{
- char *sep;
+ char *sep, *tmp;
int err;
+ /* This method requires strdup, because this changes given string */
+ if (!self->dupstr)
+ return -EINVAL;
+
while ((sep = strchr(s, ',')) != NULL) {
- *sep = '\0';
- err = strlist__parse_list_entry(self, s);
- *sep = ',';
+ tmp = strndup(s, sep - s);
+ if (tmp == NULL)
+ return -ENOMEM;
+ err = strlist__parse_list_entry(self, tmp);
+ free(tmp);
if (err != 0)
return err;
s = sep + 1;
--
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