Skip to contentSkip to conversation

fix domid length in xenconsole

PATCH New Stefano Stabellini 1 participant 1 message Jun 16, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix domid length in xenconsole

Hi all,
the last patch for xenconsole erroneously assumed that the max length of a domid in char is 3 while is obviously 5; this patch fixes it. Also snprintf includes the final '\0' in the char count.

---

tools/console/client/main.c +2 -2
diff -r 33894148c1fd tools/console/client/main.c
@@ -306,10 +306,10 @@
 	dom_path = xs_get_domain_path(xs, domid);
 	if (dom_path == NULL)
 		err(errno, "xs_get_domain_path()");
-	path = malloc(strlen(dom_path) + strlen("/serial/0/tty") + 3);
+	path = malloc(strlen(dom_path) + strlen("/serial/0/tty") + 5);
 	if (path == NULL)
 		err(ENOMEM, "malloc");
-	snprintf(path, strlen(dom_path) + strlen("/serial/0/tty") + 2, "%s/serial/%d/tty", dom_path, num);
+	snprintf(path, strlen(dom_path) + strlen("/serial/0/tty") + 5, "%s/serial/%d/tty", dom_path, num);
 
 	/* FIXME consoled currently does not assume domain-0 doesn't have a
 	   console which is good when we break domain-0 up.  To keep us