]> rtime.felk.cvut.cz Git - lisovros/qemu_apohw.git/commitdiff
vl: Tighten parsing of -m argument
authorMarkus Armbruster <armbru@redhat.com>
Tue, 22 Nov 2011 08:46:03 +0000 (09:46 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 28 Nov 2011 22:20:52 +0000 (16:20 -0600)
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>
vl.c

diff --git a/vl.c b/vl.c
index b9146cfdea1671655bfa25d0e8c1c3ce1487ba72..a50842bb7607d7e461a84c06e222337da640eb7d 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -2535,9 +2535,10 @@ int main(int argc, char **argv, char **envp)
                 break;
             case QEMU_OPTION_m: {
                 int64_t value;
+                char *end;
 
-                value = strtosz(optarg, NULL);
-                if (value < 0) {
+                value = strtosz(optarg, &end);
+                if (value < 0 || *end) {
                     fprintf(stderr, "qemu: invalid ram size: %s\n", optarg);
                     exit(1);
                 }