vl: Tighten parsing of -m argument

strtosz_suffix() fails unless the size is followed by 0, whitespace or
','.  Useless here, because we need to fail for any junk following the
size, even if it starts with whitespace or ','.  Check manually.
Things like "-m 1024," are now caught.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Markus Armbruster 2011-11-22 09:46:03 +01:00 committed by Anthony Liguori
parent c03417b438
commit 961b42b9dc

5
vl.c
View File

@ -2535,9 +2535,10 @@ int main(int argc, char **argv, char **envp)
break; break;
case QEMU_OPTION_m: { case QEMU_OPTION_m: {
int64_t value; int64_t value;
char *end;
value = strtosz(optarg, NULL); value = strtosz(optarg, &end);
if (value < 0) { if (value < 0 || *end) {
fprintf(stderr, "qemu: invalid ram size: %s\n", optarg); fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
exit(1); exit(1);
} }