ui/vnc-enc-hextile: Use static rather than dynamic length stack array
commite12acaf75d1ffadfd527180dac798368716a0001
authorPeter Maydell <peter.maydell@linaro.org>
Fri, 18 Aug 2023 15:10:56 +0000 (18 16:10 +0100)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Mon, 4 Sep 2023 10:57:44 +0000 (4 14:57 +0400)
tree51215e9c63797beb691403e5360ddb143c958ca0
parent1663ffb9157e3dc17d14741f6cd6c48bfffde9d0
ui/vnc-enc-hextile: Use static rather than dynamic length stack array

In the send_hextile_tile_* function we create a variable length array
data[].  In fact we know that the client_pf.bytes_per_pixel is at
most 4 (enforced by set_pixel_format()), so we can make the array a
compile-time fixed length of 1536 bytes.

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: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
[ Marc-André - rename BPP to MAX_BYTES_PER_PIXEL ]
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20230818151057.1541189-3-peter.maydell@linaro.org>
ui/vnc-enc-hextile-template.h