Skip to content

Commit

Permalink
detect invalid BMP image
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Dec 13, 2024
1 parent 54ddd07 commit 07a679d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions coders/bmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,12 @@ static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
bmp_info.blue_mask=ReadBlobLSBLong(image);
if (bmp_info.compression == BI_ALPHABITFIELDS)
bmp_info.alpha_mask=ReadBlobLSBLong(image);
if ((bmp_info.size == 40) ||
(bmp_info.compression == BI_ALPHABITFIELDS))
if ((bmp_info.bits_per_pixel != 16) &&
(bmp_info.bits_per_pixel != 32))
ThrowReaderException(CorruptImageError,
"UnsupportedBitsPerPixel");
}
if (bmp_info.size > 40)
{
Expand Down

0 comments on commit 07a679d

Please sign in to comment.