virHostCPUGetCPUID: Limit the buffer size ranges

Raise the lower bound to '64' as that seems to currently be the first
size that can fit the CPU data for a modern cpu.

Lower the upper bound to an arbitrary 65536. So many cpu features ougth
to be enough for everyone.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Peter Krempa 2022-04-25 13:37:52 +02:00
parent fe91f0999c
commit d946aa27c2

View File

@ -1360,7 +1360,7 @@ virHostCPUGetCPUID(void)
* the 'nent' field is adjusted and an error (ENOMEM) is returned. If the
* number is just right, the 'nent' field is adjusted to the number of valid
* entries in the 'entries' array, which is then filled. */
for (alloc_size = 1; alloc_size < INT32_MAX; alloc_size *= 2) {
for (alloc_size = 64; alloc_size <= 65536; alloc_size *= 2) {
g_autofree struct kvm_cpuid2 *kvm_cpuid = NULL;
kvm_cpuid = g_malloc0(sizeof(struct kvm_cpuid2) +