From: Cristy Date: Sat, 26 Jan 2019 16:35:25 +0000 (-0500) Subject: https://github.com/ImageMagick/ImageMagick/issues/1459 X-Git-Tag: 7.0.8-25~8 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6f77fa7061e74610608060de81f14ec54cb1aca6;p=imagemagick https://github.com/ImageMagick/ImageMagick/issues/1459 --- diff --git a/coders/bmp.c b/coders/bmp.c index d49a52b9f..83ff68820 100644 --- a/coders/bmp.c +++ b/coders/bmp.c @@ -954,11 +954,11 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception) bmp_info.bits_per_pixel<<=1; bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32); length=(size_t) bytes_per_line*image->rows; + if ((MagickSizeType) (length/256) > GetBlobSize(image)) + ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); if ((bmp_info.compression == BI_RGB) || (bmp_info.compression == BI_BITFIELDS)) { - if ((MagickSizeType) length > GetBlobSize(image)) - ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); pixel_info=AcquireVirtualMemory(image->rows, MagickMax(bytes_per_line,image->columns+256UL)*sizeof(*pixels)); if (pixel_info == (MemoryInfo *) NULL)