Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1385866

[PATCH] perf tools: fix off-by-one comparison on maximum code

From Colin King <colin.king@canonical.com>
Newsgroups linux.kernel
Subject [PATCH] perf tools: fix off-by-one comparison on maximum code
Date 2016-04-24 21:00 +0200
Message-ID <rrxq9-KK-1@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


From: Colin Ian King <colin.king@canonical.com>

The check for the maximum code is off-by-one; the current
comparison of a code that is INTEL_PT_ERR_MAX will cause the
strlcpy to perform an out of bounds array access on the
intel_pt_err_msgs array. Fix this with a >= comparison.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 tools/perf/util/intel-pt-decoder/intel-pt-decoder.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
index 9409d01..9c8f15d 100644
--- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c
@@ -356,7 +356,7 @@ static const char *intel_pt_err_msgs[] = {
 
 int intel_pt__strerror(int code, char *buf, size_t buflen)
 {
-	if (code < 1 || code > INTEL_PT_ERR_MAX)
+	if (code < 1 || code >= INTEL_PT_ERR_MAX)
 		code = INTEL_PT_ERR_UNK;
 	strlcpy(buf, intel_pt_err_msgs[code], buflen);
 	return 0;
-- 
2.7.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] perf tools: fix off-by-one comparison on maximum code Colin King <colin.king@canonical.com> - 2016-04-24 21:00 +0200
  Re: [PATCH] perf tools: fix off-by-one comparison on maximum code Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-04-26 01:30 +0200
  [tip:perf/core] perf intel-pt: Fix off-by-one comparison on maximum  code tip-bot for Colin Ian King <tipbot@zytor.com> - 2016-04-27 17:40 +0200

csiph-web