linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: Have tracecmd_msg_data_send() return zero on zero size
@ 2019-03-21 23:41 Steven Rostedt
  2019-03-22 11:49 ` Slavomir Kaslev
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2019-03-21 23:41 UTC (permalink / raw)
  To: Linux Trace Devel; +Cc: Slavomir Kaslev

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);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-22 12:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2019-03-22 12:17   ` Steven Rostedt

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).