aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (VMware) <rostedt@goodmis.org>2019-03-21 19:41:27 -0400
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-03-22 15:13:46 -0400
commit0f03474a17ac401fdd3c7d35ec7f111160dd4e9b (patch)
tree28fb3239c76ebc79f0893b287530892c54f2185f
parent2044152dd685d69bde3d79b2a25bcda3e95eac08 (diff)
downloadtrace-cmd-0f03474a17ac401fdd3c7d35ec7f111160dd4e9b.tar.gz
trace-cmd: Have tracecmd_msg_data_send() return zero on zero size
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. Link: http://lore.kernel.org/linux-trace-devel/20190321194127.4ac47d99@gandalf.local.home Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--tracecmd/trace-msg.c4
1 files changed, 4 insertions, 0 deletions
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);