Commit 5e1a14135 for imagemagick.org
commit 5e1a1413504827f5154f2397a38618028f91262c
Author: Cristy <urban-warrior@imagemagick.org>
Date: Mon Jun 22 09:13:51 2026 -0400
https://github.com/ImageMagick/ImageMagick/issues/8815
diff --git a/MagickCore/constitute-private.h b/MagickCore/constitute-private.h
index ed91dd6e1..566a98df1 100644
--- a/MagickCore/constitute-private.h
+++ b/MagickCore/constitute-private.h
@@ -27,6 +27,25 @@ extern "C" {
#include "MagickCore/log.h"
#include "MagickCore/utility.h"
+static inline MagickBooleanType IsAllowedCoder(const char *coder)
+{
+ static const char
+ *allowed_coders[] = {
+ "MPR",
+ "MPRI",
+ NULL
+ };
+
+ const char **p = allowed_coders;
+ while (*p != NULL)
+ {
+ if (LocaleCompare(coder,*p) == 0)
+ return(MagickTrue);
+ p++;
+ }
+ return(MagickFalse);
+}
+
static inline Image *StrictReadImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
@@ -36,16 +55,22 @@ static inline Image *StrictReadImage(const ImageInfo *image_info,
(void) GetPathComponent(image_info->filename,MagickPath,magic);
if (*magic != '\0')
{
- (void) ThrowMagickException(exception, GetMagickModule(),OptionError,
- "ExplicitCoderNotAllowed","`%s'",image_info->filename);
- return((Image *) NULL);
+ LocaleUpper(magic);
+ if (IsAllowedCoder(magic) == MagickFalse)
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ OptionError, "ExplicitCoderNotAllowed","`%s'",
+ image_info->filename);
+ return((Image *) NULL);
+ }
}
if (IsPathAccessible(image_info->filename) == MagickFalse)
{
- (void) ThrowMagickException(exception,GetMagickModule(),FileOpenError,
- "UnableToOpenFile","`%s'",image_info->filename);
- return((Image *) NULL);
- }
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ FileOpenError, "UnableToOpenFile","`%s'",
+ image_info->filename);
+ return((Image *) NULL);
+ }
return(ReadImage(image_info,exception));
}