perf: Fix read buffer overflow

Check whether index is within bounds before testing the element.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: a.p.zijlstra@chello.nl
Cc: Andrew Morton <akpm@linux-foundation.org>
LKML-Reference: <4A757BCF.40101@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
Roel Kluin
2009-08-02 13:43:11 +02:00
committed by Ingo Molnar
parent 59b9005692
commit 7e030655dd
2 changed files with 2 additions and 2 deletions

View File

@ -253,7 +253,7 @@ static int strcommon(const char *pathname)
{
int n = 0;
while (pathname[n] == cwd[n] && n < cwdlen)
while (n < cwdlen && pathname[n] == cwd[n])
++n;
return n;