diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 355fdb9a1e310a21e71547872bbdb3b121ba02bb..5dc57eac2f0f5cc0c5a127ed00705bebb8a4fba5 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -628,7 +628,9 @@ typedef int const char ***retcpus); /* Format: - * + * + * qemu-0.13 encloses some model names in []: + * [] */ static int qemudParseX86Models(const char *output, @@ -661,15 +663,22 @@ qemudParseX86Models(const char *output, continue; if (retcpus) { + unsigned int len; + if (VIR_REALLOC_N(cpus, count + 1) < 0) goto error; if (next) - cpus[count] = strndup(p, next - p - 1); + len = next - p - 1; else - cpus[count] = strdup(p); + len = strlen(p); + + if (len > 2 && *p == '[' && p[len - 1] == ']') { + p++; + len -= 2; + } - if (!cpus[count]) + if (!(cpus[count] = strndup(p, len))) goto error; } count++;