@@ -418,8 +418,8 @@ MagickExport Image *PingImages(const ImageInfo *image_info,
418418%
419419*/
420420
421- static MagickBooleanType IsCoderAuthorized (const char * coder ,
422- const PolicyRights rights ,ExceptionInfo * exception )
421+ static MagickBooleanType IsCoderAuthorized (const char * module ,
422+ const char * coder , const PolicyRights rights ,ExceptionInfo * exception )
423423{
424424 if (IsRightsAuthorized (CoderPolicyDomain ,rights ,coder ) == MagickFalse )
425425 {
@@ -428,6 +428,13 @@ static MagickBooleanType IsCoderAuthorized(const char *coder,
428428 "NotAuthorized" ,"`%s'" ,coder );
429429 return (MagickFalse );
430430 }
431+ if (IsRightsAuthorized (ModulePolicyDomain ,rights ,module ) == MagickFalse )
432+ {
433+ errno = EPERM ;
434+ (void ) ThrowMagickException (exception ,GetMagickModule (),PolicyError ,
435+ "NotAuthorized" ,"`%s'" ,module );
436+ return (MagickFalse );
437+ }
431438 return (MagickTrue );
432439}
433440
@@ -563,7 +570,8 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
563570 thread_support = GetMagickThreadSupport (magick_info );
564571 if ((thread_support & DecoderThreadSupport ) == 0 )
565572 LockSemaphoreInfo (magick_info -> semaphore );
566- status = IsCoderAuthorized (read_info -> magick ,ReadPolicyRights ,exception );
573+ status = IsCoderAuthorized (magick_info -> magick_module ,read_info -> magick ,
574+ ReadPolicyRights ,exception );
567575 image = (Image * ) NULL ;
568576 if (status != MagickFalse )
569577 image = GetImageDecoder (magick_info )(read_info ,exception );
@@ -628,7 +636,8 @@ MagickExport Image *ReadImage(const ImageInfo *image_info,
628636 thread_support = GetMagickThreadSupport (magick_info );
629637 if ((thread_support & DecoderThreadSupport ) == 0 )
630638 LockSemaphoreInfo (magick_info -> semaphore );
631- status = IsCoderAuthorized (read_info -> magick ,ReadPolicyRights ,exception );
639+ status = IsCoderAuthorized (magick_info -> magick_module ,read_info -> magick ,
640+ ReadPolicyRights ,exception );
632641 image = (Image * ) NULL ;
633642 if (status != MagickFalse )
634643 image = (Image * ) (GetImageDecoder (magick_info ))(read_info ,exception );
@@ -1245,7 +1254,8 @@ MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
12451254 thread_support = GetMagickThreadSupport (magick_info );
12461255 if ((thread_support & EncoderThreadSupport ) == 0 )
12471256 LockSemaphoreInfo (magick_info -> semaphore );
1248- status = IsCoderAuthorized (write_info -> magick ,WritePolicyRights ,exception );
1257+ status = IsCoderAuthorized (magick_info -> magick_module ,write_info -> magick ,
1258+ WritePolicyRights ,exception );
12491259 if (status != MagickFalse )
12501260 status = GetImageEncoder (magick_info )(write_info ,image );
12511261 if ((thread_support & EncoderThreadSupport ) == 0 )
@@ -1319,8 +1329,8 @@ MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
13191329 thread_support = GetMagickThreadSupport (magick_info );
13201330 if ((thread_support & EncoderThreadSupport ) == 0 )
13211331 LockSemaphoreInfo (magick_info -> semaphore );
1322- status = IsCoderAuthorized (write_info -> magick , WritePolicyRights ,
1323- exception );
1332+ status = IsCoderAuthorized (magick_info -> magick_module , write_info -> magick ,
1333+ WritePolicyRights , exception );
13241334 if (status != MagickFalse )
13251335 status = GetImageEncoder (magick_info )(write_info ,image );
13261336 if ((thread_support & EncoderThreadSupport ) == 0 )
0 commit comments