mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
ui/cursor: fix integer overflow in cursor_alloc (CVE-2021-4206)
Prevent potential integer overflow by limiting 'width' and 'height' to 512x512. Also change 'datasize' type to size_t. Refer to security advisory https://starlabs.sg/advisories/22-4206/ for more information. Fixes: CVE-2021-4206 Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20220407081712.345609-1-mcascell@redhat.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
parent
9569f5cb5b
commit
fa892e9abb
3 changed files with 16 additions and 1 deletions
|
@ -46,6 +46,8 @@ static QEMUCursor *cursor_parse_xpm(const char *xpm[])
|
|||
|
||||
/* parse pixel data */
|
||||
c = cursor_alloc(width, height);
|
||||
assert(c != NULL);
|
||||
|
||||
for (pixel = 0, y = 0; y < height; y++, line++) {
|
||||
for (x = 0; x < height; x++, pixel++) {
|
||||
idx = xpm[line][x];
|
||||
|
@ -91,7 +93,11 @@ QEMUCursor *cursor_builtin_left_ptr(void)
|
|||
QEMUCursor *cursor_alloc(int width, int height)
|
||||
{
|
||||
QEMUCursor *c;
|
||||
int datasize = width * height * sizeof(uint32_t);
|
||||
size_t datasize = width * height * sizeof(uint32_t);
|
||||
|
||||
if (width > 512 || height > 512) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
c = g_malloc0(sizeof(QEMUCursor) + datasize);
|
||||
c->width = width;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue