perf probe: Fix segfault if passed with ''.
authorWang Nan <wangnan0@huawei.com>
Tue, 28 Apr 2015 08:46:09 +0000 (08:46 +0000)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 5 May 2015 15:26:52 +0000 (12:26 -0300)
commite59d29e88f7b7e3d1231202b0203d0af6f15a440
treeaf3d9b41b9d35e87d6698c000f49400d3516b75e
parente944ec2ca00fb0170ba9d7f2aeec32c22dc0d4ec
perf probe: Fix segfault if passed with ''.

Since parse_perf_probe_point() deals with a user passed argument, we
should not assume it to be a valid string.

Without this patch, if pass '' to perf probe, a segfault raises:

 $ perf probe -a ''
 Segmentation fault

This patch checks argument of parse_perf_probe_point() before
string processing.

After this patch:

 $ perf probe -a ''

  usage: perf probe [<options>] 'PROBEDEF' ['PROBEDEF' ...]
     or: perf probe [<options>] --add 'PROBEDEF' [--add 'PROBEDEF' ...]
     ...

Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Zefan Li <lizefan@huawei.com>
Link: http://lkml.kernel.org/r/1430210769-94177-1-git-send-email-wangnan0@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/probe-event.c