Commit fa6bff53d for imagemagick.org
commit fa6bff53d61ca6fcb8bd19fbf23bed924dbdff7f
Author: Dirk Lemstra <dirk@lemstra.org>
Date: Sat Oct 24 20:09:23 2026 +0200
Check the number of profiles that will be added against the security policy.
diff --git a/coders/gif.c b/coders/gif.c
index d6f41b75e..02c46c778 100644
--- a/coders/gif.c
+++ b/coders/gif.c
@@ -991,7 +991,8 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
global_colors,
image_count,
local_colors,
- one;
+ one,
+ remaining_profiles;
ssize_t
count,
@@ -1054,6 +1055,7 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
duration=0;
opacity=(-1);
image_count=0;
+ remaining_profiles=GetMaxProfileCount();
for ( ; ; )
{
count=ReadBlob(image,1,&c);
@@ -1215,6 +1217,13 @@ static Image *ReadGIFImage(const ImageInfo *image_info,ExceptionInfo *exception)
info_length,exception);
if (profile != (StringInfo *) NULL)
{
+ if (remaining_profiles == 0)
+ {
+ info=(unsigned char *) RelinquishMagickMemory(info);
+ ThrowGIFException(ResourceLimitError,
+ "MaximumProfilesExceeded");
+ }
+ remaining_profiles--;
if (profiles == (LinkedListInfo *) NULL)
profiles=NewLinkedList(0);
(void) AppendValueToLinkedList(profiles,profile);