Without this check, QEMU will corrupt memory if a too-large nodeid is
provided in the command-line. e.g.:
-numa node,mem=...,cpus=...,nodeid=65
This changes nodenr to unsigned long long, to avoid integer conversion
issues when converting the strtoull() result to int.
Signed-off-by: Eduardo Habkost <[email protected]>
Reviewed-by: Eric Blake <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
char option[128];
char *endptr;
unsigned long long value, endvalue;
- int nodenr;
+ unsigned long long nodenr;
value = endvalue = 0ULL;
nodenr = strtoull(option, NULL, 10);
}
+ if (nodenr >= MAX_NODES) {
+ fprintf(stderr, "qemu: invalid NUMA nodeid: %llu\n", nodenr);
+ exit(1);
+ }
+
if (get_param_value(option, 128, "mem", optarg) == 0) {
node_mem[nodenr] = 0;
} else {