* [PATCH] trace-cmd libs: Initialize msg to NULL tracecmd_msg_read_data()
@ 2022-07-29 20:48 Steven Rostedt
0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2022-07-29 20:48 UTC (permalink / raw)
To: Linux Trace Devel
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>
If there are no parameters passed to the guest agent, then the loop
inside tracecmd_msg_read_data() will not iterate and the msg variable
will be accessed (freed) without being initailized causing a possible
SEGFAULT.
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
lib/trace-cmd/trace-msg.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/trace-cmd/trace-msg.c b/lib/trace-cmd/trace-msg.c
index 9c26401a..342d03e4 100644
--- a/lib/trace-cmd/trace-msg.c
+++ b/lib/trace-cmd/trace-msg.c
@@ -980,6 +980,8 @@ int tracecmd_msg_read_data(struct tracecmd_msg_handle *msg_handle, int ofd)
ssize_t s;
int ret;
+ memset(&msg, 0, sizeof(msg));
+
while (!tracecmd_msg_done(msg_handle)) {
n = read_msg_data(msg_handle, &msg);
if (n <= 0)
--
2.35.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-29 20:49 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-29 20:48 [PATCH] trace-cmd libs: Initialize msg to NULL tracecmd_msg_read_data() 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).