perf tools: fix handling read result
Subsystems (2)
PATCH 1/1 perf tools: fix handling read result
The function can return negative value, assigning it to unsigned variable can cause memory corruption.
The problem has been detected using proposed semantic patch scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
--- tools/perf/util/event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/event.c +2 -1
@@ -67,7 +67,8 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,char filename[PATH_MAX ];char bf[4096 ];int fd; -size_t size =0 , n; +size_t size =0 ; +ssize_t n;char *nl, *name, *tgids, *ppids; *tgid =-1 ;
Signature · 1 line
1.9.1
Em Tue, Oct 06, 2015 at 11:00:17AM +0200, Andrzej Hajda escreveu:
Quoted 7 lines
The function can return negative value, assigning it to unsigned variable can cause memory corruption.
The problem has been detected using proposed semantic patch
scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci[1].
Thanks, applied.
- Arnaldo
tip-bot for Andrzej Hajda
merge bot[tip:perf/core] perf tools: Fix handling read result using a signed variable
In reply to Andrzej Hajdaperf tools: Fix handling read result using a signed variable
Commit-ID: 38349665388fb079fb2bc8c46db9446dd976802a Gitweb: http://git.kernel.org/tip/38349665388fb079fb2bc8c46db9446dd976802a Author: Andrzej Hajda <[email protected]> AuthorDate: Tue, 6 Oct 2015 11:00:17 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Tue, 6 Oct 2015 18:04:59 -0300
perf tools: Fix handling read result using a signed variable
The function can return negative value, assigning it to unsigned variable can cause memory corruption.
The problem has been detected using proposed semantic patch scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci [1].
[1]: http://permalink.gmane.org/gmane.linux.kernel/2038576
--- tools/perf/util/event.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
tools/perf/util/event.c +2 -1
@@ -67,7 +67,8 @@ static int perf_event__get_comm_ids(pid_t pid, char *comm, size_t len,char filename[PATH_MAX ];char bf[4096 ];int fd; -size_t size =0 , n; +size_t size =0 ; +ssize_t n;char *nl, *name, *tgids, *ppids; *tgid =-1 ;