All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Colin King <colin.king@canonical.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf tools: fix off-by-one comparison on maximum code
Date: Mon, 25 Apr 2016 20:29:20 -0300	[thread overview]
Message-ID: <20160425232920.GB15298@kernel.org> (raw)
In-Reply-To: <1461524203-10224-1-git-send-email-colin.king@canonical.com>

Em Sun, Apr 24, 2016 at 07:56:43PM +0100, Colin King escreveu:
> 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.

Applied, thanks.

- Arnaldo
 
> 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

  reply	other threads:[~2016-04-25 23:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 18:56 [PATCH] perf tools: fix off-by-one comparison on maximum code Colin King
2016-04-25 23:29 ` Arnaldo Carvalho de Melo [this message]
2016-04-27 15:33 ` [tip:perf/core] perf intel-pt: Fix " tip-bot for Colin Ian King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160425232920.GB15298@kernel.org \
    --to=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=colin.king@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.