Skip to contentSkip to conversation

perf: Read buffer overflow

PATCH Applied Roel Kluin 2 participants 3 messages Aug 2, 2009 – Aug 4, 2009 perf events

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 perf: Read buffer overflow

Check whether index is within bounds before testing the element.

---

tools/perf/builtin-report.c +1 -1
index b20a4b6..edecdbe 100644
@@ -252,7 +252,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;
tools/perf/util/quote.c +1 -1
index c6e5dc0..2726fe4 100644
@@ -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;
Applied
#1 lore raw
Quoted 3 lines · Roel Kluin

Check whether index is within bounds before testing the element.

Applied, thanks Roel.

A small request for future patches: please always put a verb into Linux kernel patch titles. I.e. instead of:

perf: Read buffer overflow

use something like:

perf: Fix read buffer overflow

this holds for all the other patches you sent to lkml as well.

Thanks,

Ingo

#2 lore raw

[tip:perfcounters/urgent] perf: Fix read buffer overflow

In reply to Roel Kluin
Commit-ID:  7e030655dda5b5efc4305e2a8f46c4967d32eb3d
Gitweb:     http://git.kernel.org/tip/7e030655dda5b5efc4305e2a8f46c4967d32eb3d
Author:     Roel Kluin <[email protected]>
AuthorDate: Sun, 2 Aug 2009 13:43:11 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 4 Aug 2009 11:09:56 +0200

perf: Fix read buffer overflow

Check whether index is within bounds before testing the element.

LKML-Reference: <[email protected]>

---
 tools/perf/builtin-report.c |    2 +-
 tools/perf/util/quote.c     |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/builtin-report.c +1 -1
index 95fd06c..ce4f286 100644
@@ -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;
tools/perf/util/quote.c +1 -1
index c6e5dc0..2726fe4 100644
@@ -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;