]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vl.c: Use parse_uint_full() for NUMA nodeid
authorEduardo Habkost <ehabkost@redhat.com>
Mon, 4 Feb 2013 18:27:50 +0000 (16:27 -0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 4 Feb 2013 20:38:34 +0000 (14:38 -0600)
This should catch many kinds of errors that the current code wasn't
checking for:

 - Values that can't be parsed as a number
 - Negative values
 - Overflow
 - Empty string

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
vl.c

diff --git a/vl.c b/vl.c
index 4955c2972d0683f0f1e8cf5c70b49378e824c3e8..d6f6422de43ed8d2ebdcc55c4db049fe4f12a7d0 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1267,7 +1267,10 @@ static void numa_add(const char *optarg)
         if (get_param_value(option, 128, "nodeid", optarg) == 0) {
             nodenr = nb_numa_nodes;
         } else {
-            nodenr = strtoull(option, NULL, 10);
+            if (parse_uint_full(option, &nodenr, 10) < 0) {
+                fprintf(stderr, "qemu: Invalid NUMA nodeid: %s\n", option);
+                exit(1);
+            }
         }
 
         if (nodenr >= MAX_NODES) {