mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
To: Namhyung Kim <namhyung@gmail.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] perf build-id: Fix filename size calculation
Date: Wed, 2 May 2012 12:10:05 -0300	[thread overview]
Message-ID: <20120502151005.GA5745@infradead.org> (raw)
In-Reply-To: <1335881976-3282-1-git-send-email-namhyung@gmail.com>

Em Tue, May 01, 2012 at 11:19:36PM +0900, Namhyung Kim escreveu:
> The filename is a pointer variable so the sizeof(filename) will return
> length of a pointer. Fix it by using 'size'.

Applied.

The code worked because the snprintf buffer size parameter would always
be bigger (negative) than the sbuild_id lenght, and all fitted in the
filename allocated space. :-)

- Arnaldo
 
> Signed-off-by: Namhyung Kim <namhyung@gmail.com>
> ---
>  tools/perf/util/header.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
> index 4c7c2d73251f..c0b70c697a36 100644
> --- a/tools/perf/util/header.c
> +++ b/tools/perf/util/header.c
> @@ -296,7 +296,7 @@ int build_id_cache__add_s(const char *sbuild_id, const char *debugdir,
>  	if (mkdir_p(filename, 0755))
>  		goto out_free;
>  
> -	snprintf(filename + len, sizeof(filename) - len, "/%s", sbuild_id);
> +	snprintf(filename + len, size - len, "/%s", sbuild_id);
>  
>  	if (access(filename, F_OK)) {
>  		if (is_kallsyms) {
> -- 
> 1.7.9.2

  reply	other threads:[~2012-05-03 14:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-01 14:19 Namhyung Kim
2012-05-02 15:10 ` Arnaldo Carvalho de Melo [this message]
2012-05-02 17:43 ` [tip:perf/urgent] " tip-bot for Namhyung Kim

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=20120502151005.GA5745@infradead.org \
    --to=acme@ghostprotocols.net \
    --cc=a.p.zijlstra@chello.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@gmail.com \
    --cc=paulus@samba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome