Skip to contentSkip to conversation

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

PATCH New Steven Rostedt 1 participant 1 message Aug 16, 2022

lore
Share & tools
lore
#0 lore raw

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

From: "Steven Rostedt (Google)" <[email protected]>

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.

---
 tracecmd/trace-vm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tracecmd/trace-vm.c +1 -1
index 09bd60259258..f78f1d83386b 100644
@@ -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++)
Signature · 1 line
2.35.1