Skip to content

Commit

Permalink
check for EOF condition before setting the image background
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Feb 15, 2025
1 parent 61c6651 commit 568daab
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion coders/sct.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
MagickBooleanType
status;

MagickSizeType
extent;

MagickRealType
height,
width;
Expand Down Expand Up @@ -240,6 +243,13 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
extent=(MagickSizeType) image->rows*image->columns*separations;
if (extent > GetBlobSize(image))
{
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
return(DestroyImageList(image));
}
/*
Convert SCT raster image to pixel packets.
*/
Expand Down Expand Up @@ -294,7 +304,8 @@ static Image *ReadSCTImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if ((image->columns % 2) != 0)
(void) ReadBlobByte(image); /* pad */
if (ReadBlobByte(image) == EOF) /* pad */
break;
}
if (i < (ssize_t) separations)
break;
Expand Down

0 comments on commit 568daab

Please sign in to comment.