linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: tz.stoyanov@gmail.com, rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: Re: [PATCH] trace-cmd: Fixed a potential problem with non-terminated string, returned by readlink()
Date: Thu, 4 Jul 2019 15:39:37 +0300	[thread overview]
Message-ID: <513a3420-56da-f1b3-4798-e8aff2ee58c5@gmail.com> (raw)
In-Reply-To: <20190703121644.18680-1-tz.stoyanov@gmail.com>



On 3.07.19 г. 15:16 ч., tz.stoyanov@gmail.com wrote:
> From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
> 
> The buffer, returned by readlink() API, is not guaranteed to be a null terminated string.
> Explicitly adding '\0' at the end of the buffer is recommended, to ensure the string is
> null terminated and to avoid possible buffer overruns.
> 
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
>   lib/trace-cmd/trace-util.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/lib/trace-cmd/trace-util.c b/lib/trace-cmd/trace-util.c
> index 190cf74..7c74bae 100644
> --- a/lib/trace-cmd/trace-util.c
> +++ b/lib/trace-cmd/trace-util.c
> @@ -1373,6 +1373,7 @@ static char *trace_util_get_source_plugins_dir(void)
>   	ret = readlink("/proc/self/exe", path, PATH_MAX);
>   	if (ret > PATH_MAX || ret < 0)
>   		return NULL;
> +	path[ret] = 0;
>   
>   	dirname(path);
>   	p = strrchr(path, '/');
> 

Thanks!

Reviewed-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
Tested-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>

      reply	other threads:[~2019-07-04 12:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 12:16 [PATCH] trace-cmd: Fixed a potential problem with non-terminated string, returned by readlink() tz.stoyanov
2019-07-04 12:39 ` Yordan Karadzhov (VMware) [this message]

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=513a3420-56da-f1b3-4798-e8aff2ee58c5@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=tz.stoyanov@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).