linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Slavomir Kaslev <kaslevs@vmware.com>
To: "rostedt@goodmis.org" <rostedt@goodmis.org>,
	"linux-trace-devel@vger.kernel.org" 
	<linux-trace-devel@vger.kernel.org>
Subject: Re: [PATCH] trace-cmd: Have tracecmd_msg_data_send() return zero on zero size
Date: Fri, 22 Mar 2019 11:49:29 +0000	[thread overview]
Message-ID: <66ec4786aecc3585081b932ab96b700f13f78d96.camel@vmware.com> (raw)
In-Reply-To: <20190321194127.4ac47d99@gandalf.local.home>

On Thu, 2019-03-21 at 19:41 -0400, Steven Rostedt wrote:
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
> 
> If tracecmd_msg_data_send() is passed a size of zero, the loop is not
> entered, nothing is sent, but the ret variable is not initialized and
> garbage can be sent out. The option code can call this with a size of
> zero,
> which can cause an error report.
> 
> Just don't do anything in this case, and return a success.
> 
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  tracecmd/trace-msg.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tracecmd/trace-msg.c b/tracecmd/trace-msg.c
> index 51d0ac8b..382bd766 100644
> --- a/tracecmd/trace-msg.c
> +++ b/tracecmd/trace-msg.c
> @@ -590,6 +590,10 @@ int tracecmd_msg_data_send(struct
> tracecmd_msg_handle *msg_handle,
>  	int ret;
>  	int count = 0;
>  
> +	/* Don't bother doing anything if there's nothing to do */
> +	if (!size)
> +		return 0;
> +
>  	tracecmd_msg_init(MSG_SEND_DATA, &msg);
>  
>  	msg.buf = malloc(MSG_MAX_DATA_LEN);

Nice catch. Definitely a latent bug waiting for someone to step on it.

Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com>

-- Slavi

  reply	other threads:[~2019-03-22 11:49 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 23:41 [PATCH] trace-cmd: Have tracecmd_msg_data_send() return zero on zero size Steven Rostedt
2019-03-22 11:49 ` Slavomir Kaslev [this message]
2019-03-22 12:17   ` Steven Rostedt

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=66ec4786aecc3585081b932ab96b700f13f78d96.camel@vmware.com \
    --to=kaslevs@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.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;
as well as URLs for NNTP newsgroup(s).