From: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
To: Hyeoncheol Lee <hyc.lee@gmail.com>
Cc: acme@ghostprotocols.net, LKML <linux-kernel@vger.kernel.org>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
"yrl.pp-manager.tt@hitachi.com" <yrl.pp-manager.tt@hitachi.com>
Subject: Re: [PATCH] perf probe: convert_name_to_addr() allocated the wrong size buffer for a function name
Date: Tue, 16 Oct 2012 13:19:57 +0900 [thread overview]
Message-ID: <507CE06D.8050806@hitachi.com> (raw)
In-Reply-To: <1350351452-9737-1-git-send-email-hyc.lee@gmail.com>
(2012/10/16 10:37), Hyeoncheol Lee wrote:
> convert_name_to_addr() allocated sizeof(char *) * MAX_PROBE_ARGS
> bytes for a function name
Yeah, that one was from my laziness...
>
> Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
> Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
> Signed-off-by: Hyeoncheol Lee <hyc.lee@gmail.com>
> ---
> tools/perf/util/probe-event.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 49a256e..bb40ed4 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -2352,13 +2352,14 @@ static int convert_name_to_addr(struct perf_probe_event *pev, const char *exec)
> free(exec_copy);
> }
> free(pp->function);
> - pp->function = zalloc(sizeof(char *) * MAX_PROBE_ARGS);
> + pp->function = zalloc(sizeof(char) *
> + (3 + sizeof(unsigned long long) * 2));
Could you comment that this is enough long here?
> if (!pp->function) {
> ret = -ENOMEM;
> pr_warning("Failed to allocate memory by zalloc.\n");
> goto out;
> }
> - e_snprintf(pp->function, MAX_PROBE_ARGS, "0x%llx", vaddr);
> + sprintf(pp->function, "0x%llx", vaddr);
And at least we should use snprintf instead of sprintf...
(I think ret = e_snprintf(...) is better)
> ret = 0;
>
> out:
>
Thank you,
--
Masami HIRAMATSU
IT Management Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com
next prev parent reply other threads:[~2012-10-16 4:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-16 1:37 [PATCH] perf probe: convert_name_to_addr() allocated the wrong size buffer for a function name Hyeoncheol Lee
2012-10-16 4:19 ` Masami Hiramatsu [this message]
2012-10-16 4:39 ` Srikar Dronamraju
2012-10-16 8:16 ` Hyeoncheol Lee
2012-10-16 8:13 ` Hyeoncheol Lee
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=507CE06D.8050806@hitachi.com \
--to=masami.hiramatsu.pt@hitachi.com \
--cc=acme@ghostprotocols.net \
--cc=hyc.lee@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=srikar@linux.vnet.ibm.com \
--cc=yrl.pp-manager.tt@hitachi.com \
/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.