ia64/xen-unstable

changeset 19774:74911141ce79

xenconsole: fix assumption about printed max domid length.
Also snprintf includes the final '\0' in the char count.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jun 17 07:23:06 2009 +0100 (2009-06-17)
parents 11d8ca329b54
children bda5ab0cb387
files tools/console/client/main.c
line diff
     1.1 --- a/tools/console/client/main.c	Wed Jun 17 07:22:18 2009 +0100
     1.2 +++ b/tools/console/client/main.c	Wed Jun 17 07:23:06 2009 +0100
     1.3 @@ -306,10 +306,10 @@ int main(int argc, char **argv)
     1.4  	dom_path = xs_get_domain_path(xs, domid);
     1.5  	if (dom_path == NULL)
     1.6  		err(errno, "xs_get_domain_path()");
     1.7 -	path = malloc(strlen(dom_path) + strlen("/serial/0/tty") + 3);
     1.8 +	path = malloc(strlen(dom_path) + strlen("/serial/0/tty") + 5);
     1.9  	if (path == NULL)
    1.10  		err(ENOMEM, "malloc");
    1.11 -	snprintf(path, strlen(dom_path) + strlen("/serial/0/tty") + 2, "%s/serial/%d/tty", dom_path, num);
    1.12 +	snprintf(path, strlen(dom_path) + strlen("/serial/0/tty") + 5, "%s/serial/%d/tty", dom_path, num);
    1.13  
    1.14  	/* FIXME consoled currently does not assume domain-0 doesn't have a
    1.15  	   console which is good when we break domain-0 up.  To keep us