Skip to contentSkip to conversation

perf tools: Don't allow empty argument for field-separator.

PATCH Applied Wang Nan 3 participants 3 messages Mar 20, 2015 – Mar 22, 2015 perf events

lore
Share & tools
lore

Wang Nan

author
#0 lore raw

PATCH 1/1 perf tools: Don't allow empty argument for field-separator.

Both 'perf diff' and 'perf mem' have 'field-separator' option, which causes segfault if passed with empty string. This patch uses previously introduced 'OPT_STRING_NOEMPTY' option macro to prevent fault.

---
This patch is based on Arnaldo's pull request for Ingo:
Commit 0c8c20779c5d56b93b8cb4cd30ba129a927ab437

---
 tools/perf/builtin-diff.c | 2 +-
 tools/perf/builtin-mem.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-diff.c +1 -1
index f800fc9..473887d 100644
@@ -802,7 +802,7 @@ static const struct option options[] = {
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
 		   " Please refer the man page for the complete list."),
-	OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
+	OPT_STRING_NOEMPTY('t', "field-separator", &symbol_conf.field_sep, "separator",
 		   "separator for columns, no spaces will be added between "
 		   "columns '.' is reserved."),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
tools/perf/builtin-mem.c +1 -1
index 46c6931..b4dcf0b 100644
@@ -286,7 +286,7 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
 		   "input file name"),
 	OPT_STRING('C', "cpu", &mem.cpu_list, "cpu",
 		   "list of cpus to profile"),
-	OPT_STRING('x', "field-separator", &symbol_conf.field_sep,
+	OPT_STRING_NOEMPTY('x', "field-separator", &symbol_conf.field_sep,
 		   "separator",
 		   "separator for columns, no spaces will be added"
 		   " between columns '.' is reserved."),
Signature · 1 line
1.8.3.4
maintainer Applied
#1 lore raw

Em Fri, Mar 20, 2015 at 02:57:52AM +0000, Wang Nan escreveu:

Quoted 5 lines

Both 'perf diff' and 'perf mem' have 'field-separator' option, which causes segfault if passed with empty string. This patch uses previously introduced 'OPT_STRING_NOEMPTY' option macro to prevent fault.

Thanks, applied.

- Arnaldo

#2 lore raw

[tip:perf/core] perf tools: Don' t allow empty argument for field-separator

In reply to Wang Nan
perf tools: Don't allow empty argument for field-separator
Commit-ID:  8b8ca6e15e392b366a7d69c6bf1abaae005f2b63
Gitweb:     http://git.kernel.org/tip/8b8ca6e15e392b366a7d69c6bf1abaae005f2b63
Author:     Wang Nan <[email protected]>
AuthorDate: Fri, 20 Mar 2015 02:57:52 +0000
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 20 Mar 2015 17:49:51 -0300

perf tools: Don't allow empty argument for field-separator

Both 'perf diff' and 'perf mem' have 'field-separator' option, which causes segfault if passed with empty string. This patch uses previously introduced 'OPT_STRING_NOEMPTY' option macro to prevent fault.

---
 tools/perf/builtin-diff.c | 2 +-
 tools/perf/builtin-mem.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-diff.c +1 -1
index f800fc9..473887d 100644
@@ -802,7 +802,7 @@ static const struct option options[] = {
 	OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
 		   "sort by key(s): pid, comm, dso, symbol, parent, cpu, srcline, ..."
 		   " Please refer the man page for the complete list."),
-	OPT_STRING('t', "field-separator", &symbol_conf.field_sep, "separator",
+	OPT_STRING_NOEMPTY('t', "field-separator", &symbol_conf.field_sep, "separator",
 		   "separator for columns, no spaces will be added between "
 		   "columns '.' is reserved."),
 	OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
tools/perf/builtin-mem.c +1 -1
index 46c6931..b4dcf0b 100644
@@ -286,7 +286,7 @@ int cmd_mem(int argc, const char **argv, const char *prefix __maybe_unused)
 		   "input file name"),
 	OPT_STRING('C', "cpu", &mem.cpu_list, "cpu",
 		   "list of cpus to profile"),
-	OPT_STRING('x', "field-separator", &symbol_conf.field_sep,
+	OPT_STRING_NOEMPTY('x', "field-separator", &symbol_conf.field_sep,
 		   "separator",
 		   "separator for columns, no spaces will be added"
 		   " between columns '.' is reserved."),