]> git.proxmox.com Git - mirror_qemu.git/commit
block/vpc: Avoid dynamic stack allocation
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Fri, 11 Aug 2023 17:52:29 +0000 (18:52 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 8 Sep 2023 15:03:09 +0000 (17:03 +0200)
commit3c2c599c79eea9cebd7280140a5901fe3734e94e
treefb47cc53bace6356f2350d9cd169bbdefe7952f3
parent13d9f6dca08a38e9258b6328f3ad61bdb8e19619
block/vpc: Avoid dynamic stack allocation

Use autofree heap allocation instead of variable-length array on the
stack. Here we don't expect the bitmap size to be enormous, and
since we're about to read/write it to disk the overhead of the
allocation should be fine.

The codebase has very few VLAs, and if we can get rid of them all we
can make the compiler error on new additions.  This is a defensive
measure against security bugs where an on-stack dynamic allocation
isn't correctly size-checked (e.g.  CVE-2021-3527).

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
[PMM: expanded commit message]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-ID: <20230811175229.808139-1-peter.maydell@linaro.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Francisco Iglesias <frasse.iglesias@gmail.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/vpc.c