Commit 7e030655 authored by Roel Kluin's avatar Roel Kluin Committed by Ingo Molnar

perf: Fix read buffer overflow

Check whether index is within bounds before testing the element.
Signed-off-by: default avatarRoel 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: default avatarIngo Molnar <mingo@elte.hu>
parent 59b90056
...@@ -253,7 +253,7 @@ static int strcommon(const char *pathname) ...@@ -253,7 +253,7 @@ static int strcommon(const char *pathname)
{ {
int n = 0; int n = 0;
while (pathname[n] == cwd[n] && n < cwdlen) while (n < cwdlen && pathname[n] == cwd[n])
++n; ++n;
return n; return n;
......
...@@ -318,7 +318,7 @@ char *quote_path_relative(const char *in, int len, ...@@ -318,7 +318,7 @@ char *quote_path_relative(const char *in, int len,
strbuf_addch(out, '"'); strbuf_addch(out, '"');
if (prefix) { if (prefix) {
int off = 0; int off = 0;
while (prefix[off] && off < len && prefix[off] == in[off]) while (off < len && prefix[off] && prefix[off] == in[off])
if (prefix[off] == '/') { if (prefix[off] == '/') {
prefix += off + 1; prefix += off + 1;
in += off + 1; in += off + 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment