]> git.ipfire.org Git - thirdparty/libvirt.git/commit
virHostCPUGetCPUID: Fix possible allocation of huge amount of memory
authorPeter Krempa <pkrempa@redhat.com>
Mon, 25 Apr 2022 11:36:26 +0000 (13:36 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 25 Apr 2022 14:38:01 +0000 (16:38 +0200)
commitfe91f0999c9ab9f8c19c0f1bd8b65b576734e483
treeae88e6692bc025008bbb7b083538f47c72390687
parent231a6db96dabb9fa1c1d382c544fcc5aa771f5fb
virHostCPUGetCPUID: Fix possible allocation of huge amount of memory

In case when the 'KVM_GET_SUPPORTED_CPUID' ioctl on /dev/kvm would
fail for other reason than the documented E2BIG, our code would continue
looping and calling it while always increasing the memory buffer even
when that will not help.

Rewrite the function to allow another iteration only with the correct
errno.

Additionally rename the 'i' variable to 'alloc_size' as it's not a pure
iterator.

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