]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
perf: Fix read buffer overflow
authorRoel Kluin <roel.kluin@gmail.com>
Sun, 2 Aug 2009 11:43:11 +0000 (13:43 +0200)
committerIngo Molnar <mingo@elte.hu>
Tue, 4 Aug 2009 09:09:56 +0000 (11:09 +0200)
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>
tools/perf/builtin-report.c
tools/perf/util/quote.c

index 95fd06cdaa99260bebaac42b98374bee1f5bc9ed..ce4f28645e6438069c1b20a33c2a13f9cb18d7ce 100644 (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;
index c6e5dc0dc82f632dc2b1ae44b5f8e51f707b1755..2726fe40eb5dd2483d16ab3064caa91eea92c62e 100644 (file)
@@ -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;