Skip to content

Commit

Permalink
limit the number of XCF layers
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Aug 6, 2023
1 parent 0682575 commit a4137de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions coders/xcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1405,13 +1405,17 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
}
else
{
int
current_layer = 0,
foundAllLayers = MagickFalse,
MagickBooleanType
foundAllLayers = MagickFalse;

MagickOffsetType
oldPos = TellBlob(image);

size_t
number_layers = 0;

MagickOffsetType
oldPos=TellBlob(image);
ssize_t
current_layer = 0;

XCFLayerInfo
*layer_info;
Expand All @@ -1425,7 +1429,12 @@ static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
if (offset == 0)
foundAllLayers=MagickTrue;
else
number_layers++;
{
number_layers++;
if ((ssize_t) number_layers == SSIZE_MAX)
ThrowReaderException(ResourceLimitError,
"ListLengthExceedsLimit");
}
if (EOFBlob(image) != MagickFalse)
{
ThrowFileException(exception,CorruptImageError,
Expand Down
2 changes: 1 addition & 1 deletion magick/gem.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ extern "C" {
#endif

extern MagickExport double
ExpandAffine(const AffineMatrix *),
ExpandAffine(const AffineMatrix *) magick_attribute((__pure__)),
GenerateDifferentialNoise(RandomInfo *,const Quantum,const NoiseType,
const MagickRealType);

Expand Down

0 comments on commit a4137de

Please sign in to comment.