Skip to content

Commit

Permalink
[codec,planar] check resolution for overflow
Browse files Browse the repository at this point in the history
If the codec resolution is too large return an error as the internal
buffers would otherwise overflow.
  • Loading branch information
Armin Novak authored and akallabeth committed Jan 16, 2024
1 parent a842350 commit 939e922
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libfreerdp/codec/planar.c
Expand Up @@ -1655,7 +1655,13 @@ BOOL freerdp_bitmap_planar_context_reset(BITMAP_PLANAR_CONTEXT* context, UINT32
context->bgr = FALSE;
context->maxWidth = PLANAR_ALIGN(width, 4);
context->maxHeight = PLANAR_ALIGN(height, 4);
context->maxPlaneSize = context->maxWidth * context->maxHeight;
const UINT64 tmp = (UINT64)context->maxWidth * context->maxHeight;
if (tmp > UINT32_MAX)
return FALSE;
context->maxPlaneSize = tmp;

if (context->maxWidth > UINT32_MAX / 4)
return FALSE;
context->nTempStep = context->maxWidth * 4;

memset(context->planes, 0, sizeof(context->planes));
Expand Down

0 comments on commit 939e922

Please sign in to comment.