From: Han Pingtian Date: Thu, 6 Jan 2011 09:39:22 +0000 (+0800) Subject: perf tools: Fix buffer overflow error when specifying all tracepoints X-Git-Tag: v2.6.38-rc1~417^2~21 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f006d25a15216a483cec71e886786874f66f9452;p=pandora-kernel.git perf tools: Fix buffer overflow error when specifying all tracepoints I found when specifying all tracepoints with -e to one of subcommand, such as 'stat', the program will trigger a buffer overflow error, like this: *** buffer overflow detected ***: ./perf terminated ======= Backtrace: ========= /lib64/libc.so.6(__fortify_fail+0x37)[0x382cefb2c7] .... The tracepoints are separated by comma, something like this: $ perf stat -a -e `perf list |grep Tracepoint|awk -F'[' '{gsub(/[[:space:]]+/,"",$1);array[FNR]=$1}END{outputs=array[1];for (i=2;i<=FNR;i++){ outputs=outputs "," array[i];};print outputs}'` The root reason of this problem is that store_event_type() is called for all events, and will overflow the 'filename' at: strncat(filename, orgname, strlen(orgname)); This patch fixes it by calling store_event_type() only when the event name has been found. LKML-Reference: <20110106093922.GB6713@hpt.nay.redhat.com> Signed-off-by: Han Pingtian Signed-off-by: Arnaldo Carvalho de Melo --- Reading git-diff-tree failed