Skip to contentSkip to conversation

tools/xenconsole: fix Segmentation fault

PATCH New Yu Zhiguo 1 participant 1 message Feb 8, 2010

lore
Share & tools
lore

Yu Zhiguo

author
#0 lore raw

PATCH 1/1 tools/xenconsole: fix Segmentation fault

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

tools/console/client/main.c +7 -1
diff -r 7b751b0e6f1b -r 22dfbd21b44e tools/console/client/main.c
@@ -287,7 +287,13 @@
 			exit(EINVAL);
 		}
 	}
-	
+
+	if (optind >= argc) {
+		fprintf(stderr, "DOMID should be specified\n");
+		fprintf(stderr, "Try `%s --help' for more information.\n",
+			argv[0]);
+		exit(EINVAL);
+	}
 	domid = strtol(argv[optind], &end, 10);
 	if (end && *end) {
 		fprintf(stderr, "Invalid DOMID `%s'\n", argv[optind]);