diff mbox series

trace-cmd: Do not return zero length name for guest by name

Message ID 20220815172056.37ec14c8@gandalf.local.home (mailing list archive)
State Superseded
Headers show
Series trace-cmd: Do not return zero length name for guest by name | expand

Commit Message

Steven Rostedt Aug. 15, 2022, 9:20 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The function trace_get_guest() will first look for a guest by name, and
if it finds one, it will return it. But if the guest added did not have
a name (but had an empty string), it would return any guest that also
did not have a name (but just an empty string). If two guests did not
have a name, and the CID was used, then the first guest would be
returned for the second guest, breaking the creating of two guests where
both were without names.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-vm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-vm.c b/tracecmd/trace-vm.c
index 09bd60259258..f78f1d83386b 100644
--- a/tracecmd/trace-vm.c
+++ b/tracecmd/trace-vm.c
@@ -35,7 +35,7 @@  static struct trace_guest *get_guest_by_name(const char *name)
 {
 	int i;
 
-	if (!guests)
+	if (!guests || !strlen(name))
 		return NULL;
 
 	for (i = 0; i < guests_len; i++)