From a432a297ca6f3abf1b30f72030d80f741e23e7f1 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 17 Oct 2018 11:36:32 +0200 Subject: [PATCH] Fixed division by 0 if invalid formats are used. --- libfreerdp/gdi/graphics.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libfreerdp/gdi/graphics.c b/libfreerdp/gdi/graphics.c index 6117ab1e2..3ba73fe6b 100644 --- a/libfreerdp/gdi/graphics.c +++ b/libfreerdp/gdi/graphics.c @@ -176,10 +176,16 @@ static BOOL gdi_Bitmap_Decompress(rdpContext* context, rdpBitmap* bitmap, const UINT32 SrcFormat = gdi_get_pixel_format(bpp); const size_t sbpp = GetBytesPerPixel(SrcFormat); const size_t dbpp = GetBytesPerPixel(bitmap->format); - const size_t dstSize = SrcSize * dbpp / sbpp; - if (dstSize < bitmap->length) + if ((sbpp == 0) || (dbpp == 0)) return FALSE; + else + { + const size_t dstSize = SrcSize * dbpp / sbpp; + + if (dstSize < bitmap->length) + return FALSE; + } if (!freerdp_image_copy(bitmap->data, bitmap->format, 0, 0, 0, DstWidth, DstHeight, pSrcData, SrcFormat,