提交 3970a2dc 编写于 作者: J Jim Meyering

cpu_x86.c: avoid NULL-deref for invalid arguments

* src/cpu/cpu_x86.c (x86Decode): Do not dereference NULL
when "models" is NULL and nmodels is 1 or greater.
上级 b74aadb3
/* /*
* cpu_x86.c: CPU driver for CPUs with x86 compatible CPUID instruction * cpu_x86.c: CPU driver for CPUs with x86 compatible CPUID instruction
* *
* Copyright (C) 2009 Red Hat, Inc. * Copyright (C) 2009-2010 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -954,6 +954,9 @@ x86Decode(virCPUDefPtr cpu, ...@@ -954,6 +954,9 @@ x86Decode(virCPUDefPtr cpu,
if (data == NULL || (map = x86LoadMap()) == NULL) if (data == NULL || (map = x86LoadMap()) == NULL)
return -1; return -1;
if (models == NULL && nmodels != 0)
return -1;
candidate = map->models; candidate = map->models;
while (candidate != NULL) { while (candidate != NULL) {
bool allowed = (models == NULL); bool allowed = (models == NULL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册