From: Roel Kluin Date: Sun, 2 Aug 2009 11:43:11 +0000 (+0200) Subject: perf: Fix read buffer overflow X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7e030655dda5b5efc4305e2a8f46c4967d32eb3d;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git perf: Fix read buffer overflow Check whether index is within bounds before testing the element. Signed-off-by: Roel Kluin Cc: a.p.zijlstra@chello.nl Cc: Andrew Morton LKML-Reference: <4A757BCF.40101@gmail.com> Signed-off-by: Ingo Molnar --- diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 95fd06cdaa9..ce4f28645e6 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -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; diff --git a/tools/perf/util/quote.c b/tools/perf/util/quote.c index c6e5dc0dc82..2726fe40eb5 100644 --- a/tools/perf/util/quote.c +++ b/tools/perf/util/quote.c @@ -318,7 +318,7 @@ char *quote_path_relative(const char *in, int len, strbuf_addch(out, '"'); if (prefix) { int off = 0; - while (prefix[off] && off < len && prefix[off] == in[off]) + while (off < len && prefix[off] && prefix[off] == in[off]) if (prefix[off] == '/') { prefix += off + 1; in += off + 1;