debuggers.hg

changeset 20956:5e49312fcb44

tools/xenconsole: fix Segmentation fault

Segmentation fault occurs if DOMID isn't specified.
Some check be added to output error message in this situation.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
author Keir Fraser <keir.fraser@citrix.com>
date Mon Feb 08 08:50:03 2010 +0000 (2010-02-08)
parents 12fc55dffb6b
children f330b15f885d
files tools/console/client/main.c
line diff
     1.1 --- a/tools/console/client/main.c	Mon Feb 08 08:49:19 2010 +0000
     1.2 +++ b/tools/console/client/main.c	Mon Feb 08 08:50:03 2010 +0000
     1.3 @@ -287,7 +287,13 @@ int main(int argc, char **argv)
     1.4  			exit(EINVAL);
     1.5  		}
     1.6  	}
     1.7 -	
     1.8 +
     1.9 +	if (optind >= argc) {
    1.10 +		fprintf(stderr, "DOMID should be specified\n");
    1.11 +		fprintf(stderr, "Try `%s --help' for more information.\n",
    1.12 +			argv[0]);
    1.13 +		exit(EINVAL);
    1.14 +	}
    1.15  	domid = strtol(argv[optind], &end, 10);
    1.16  	if (end && *end) {
    1.17  		fprintf(stderr, "Invalid DOMID `%s'\n", argv[optind]);