Commit 4e9ccb943 for imagemagick.org
commit 4e9ccb943ec8f567a557c6e70227752742bd5f57
Author: Cristy <urban-warrior@imagemagick.org>
Date: Fri Dec 4 18:42:30 2026 -0500
WriteINFOImage now validates its exception argument
diff --git a/coders/info.c b/coders/info.c
index 87b2d8abf..1331c691b 100644
--- a/coders/info.c
+++ b/coders/info.c
@@ -182,6 +182,8 @@ static MagickBooleanType WriteINFOImage(const ImageInfo *image_info,
assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickCoreSignature);
if (IsEventLogging() != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
status=OpenBlob(image_info,image,WriteBlobMode,exception);
@@ -198,16 +200,17 @@ static MagickBooleanType WriteINFOImage(const ImageInfo *image_info,
return(MagickFalse);
}
clone_info=CloneImageInfo(image_info);
+ format=GetImageOption(image_info,"format");
do
{
- format=GetImageOption(image_info,"format");
if (format == (char *) NULL)
{
(void) CopyMagickString(image->filename,image->magick_filename,
MagickPathExtent);
image->magick_columns=image->columns;
image->magick_rows=image->rows;
- (void) IdentifyImage(image,file,image_info->verbose,exception);
+ if (IdentifyImage(image,file,image_info->verbose,exception) == MagickFalse)
+ status=MagickFalse;
}
else
{
@@ -218,10 +221,17 @@ static MagickBooleanType WriteINFOImage(const ImageInfo *image_info,
exception);
if (text != (char *) NULL)
{
- (void) WriteBlobString(image,text);
+ size_t
+ length;
+
+ length=strlen(text);
+ if (WriteBlobString(image,text) != (ssize_t) length)
+ status=MagickFalse;
text=DestroyString(text);
}
}
+ if (status == MagickFalse)
+ break;
if (GetNextImageInList(image) == (Image *) NULL)
break;
image=SyncNextImageInList(image);