]> Git Repo - qemu.git/commitdiff
vl.c: Fix off-by-one bug when handling "-numa node" argument
authorEduardo Habkost <[email protected]>
Mon, 4 Feb 2013 18:27:46 +0000 (16:27 -0200)
committerAnthony Liguori <[email protected]>
Mon, 4 Feb 2013 20:38:33 +0000 (14:38 -0600)
The numa_add() code was unconditionally adding 1 to the get_opt_name()
return value, making it point after the end of the string if no ','
separator is present.

Example of weird behavior caused by the bug:

  $ qemu-img create -f qcow2 this-file-image-has,cpus=5,mem=1000,in-its-name.qcow2 5G
  Formatting 'this-file-image-has,cpus=5,mem=1000,in-its-name.qcow2', fmt=qcow2 size=5368709120 encryption=off cluster_size=65536
  $ ./x86_64-softmmu/qemu-system-x86_64 -S -monitor stdio -numa node 'this-file-image-has,cpus=5,mem=1000,in-its-name.qcow2'
  QEMU 1.3.50 monitor - type 'help' for more information
  (qemu) info numa
  1 nodes
  node 0 cpus: 0
  node 0 size: 1000 MB
  (qemu)

This changes the code to nove the pointer only if ',' is found.

Signed-off-by: Eduardo Habkost <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
vl.c

diff --git a/vl.c b/vl.c
index 315598994fe0bf973710dcfef8afd5ad284b669c..0dae44cd602bc866e0c21588239e47db3edd56ba 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -1253,7 +1253,10 @@ static void numa_add(const char *optarg)
 
     value = endvalue = 0ULL;
 
-    optarg = get_opt_name(option, 128, optarg, ',') + 1;
+    optarg = get_opt_name(option, 128, optarg, ',');
+    if (*optarg == ',') {
+        optarg++;
+    }
     if (!strcmp(option, "node")) {
         if (get_param_value(option, 128, "nodeid", optarg) == 0) {
             nodenr = nb_numa_nodes;
This page took 0.031558 seconds and 4 git commands to generate.