]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virHostCPUGetCPUID: Limit the buffer size ranges
authorPeter Krempa <pkrempa@redhat.com>
Mon, 25 Apr 2022 11:37:52 +0000 (13:37 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 25 Apr 2022 14:38:01 +0000 (16:38 +0200)
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>
src/util/virhostcpu.c

index aa21c567be6fda1471bb9346d222d5e95a16f883..9a9fcf11c0fe2af43f9e31fc4baf86855ea994b9 100644 (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) +