aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2016-04-24 14:56:43 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2016-04-25 19:35:59 -0400
commitc0664893050cc6b2d8b02d3e035f82fbfd0cd4cf (patch)
tree2ae1f9be240f18add8a931100d07ca417fad2aca
parent73b1794e252b0476cc6e46461c7612cbaa88be45 (diff)
perf intel-pt: Fix off-by-one comparison on maximum code
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> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/1461524203-10224-1-git-send-email-colin.king@canonical.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/intel-pt-decoder/intel-pt-decoder.c2
1 files changed, 1 insertions, 1 deletions
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 9409d014b46c..9c8f15da86ce 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[] = {
356 356
357int intel_pt__strerror(int code, char *buf, size_t buflen) 357int intel_pt__strerror(int code, char *buf, size_t buflen)
358{ 358{
359 if (code < 1 || code > INTEL_PT_ERR_MAX) 359 if (code < 1 || code >= INTEL_PT_ERR_MAX)
360 code = INTEL_PT_ERR_UNK; 360 code = INTEL_PT_ERR_UNK;
361 strlcpy(buf, intel_pt_err_msgs[code], buflen); 361 strlcpy(buf, intel_pt_err_msgs[code], buflen);
362 return 0; 362 return 0;