trace-cmd: Have tracecmd_msg_data_send() return zero on zero size
PATCH 1/1 trace-cmd: Have tracecmd_msg_data_send() return zero on zero size
From: "Steven Rostedt (VMware)" <[email protected]>
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.
--- tracecmd/trace-msg.c | 4 ++++ 1 file changed, 4 insertions(+)
tracecmd/trace-msg.c +4 -0
@@ -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 );
Signature · 1 line
2.20.1
Quoted 30 lines · Steven Rostedt
From: "Steven Rostedt (VMware)" <[email protected]>
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) <[email protected]>--- tracecmd/trace-msg.c | 4 ++++ 1 file changed, 4 insertions(+)tracecmd/trace-msg.c +4
-0@@ -590,6 +590,10 @@ int tracecmd_msg_data_send(structtracecmd_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);
Quoted 1 line
msg.buf =
malloc(MSG_MAX_DATA_LEN);
Nice catch. Definitely a latent bug waiting for someone to step on it.
-- Slavi
Quoted 15 lines · On Fri, 22 Mar 2019 11:49:29 +0000 Slavomir Kaslev <[email protected]> wrote:
Quoted 15 lines
tracecmd/trace-msg.c +4
-0@@ -590,6 +590,10 @@ int tracecmd_msg_data_send(structtracecmd_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);
Quoted 5 lines
Quoted 1 line
msg.buf =
malloc(MSG_MAX_DATA_LEN);Nice catch. Definitely a latent bug waiting for someone to step on it.
Reviewed-by Slavomir Kaslev <[email protected]>
Yeah, it tripped me up, as I had a box that crashed because of it. Delaying the finishing of the testing. Which I'm rerunning now.
-- Steve