Skip to content

Commit 1d452bb

Browse files
committed
Disabling a module will now also disable all the coders in that module.
1 parent e4f6cea commit 1d452bb

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

config/policy-limited.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
<!-- Indirect reads are not permitted. -->
8686
<policy domain="path" rights="none" pattern="@*"/>
8787
<!-- These image types are security risks on read, but write is fine -->
88-
<policy domain="coder" rights="write" pattern="{MSL,MVG,PS,SVG,URL,XPS}"/>
8988
<policy domain="module" rights="write" pattern="{MSL,MVG,PS,SVG,URL,XPS}"/>
9089
<!-- This policy sets the number of times to replace content of certain
9190
memory buffers and temporary files before they are freed or deleted. -->

config/policy-open.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@
140140
<!-- Indirect reads are not permitted. -->
141141
<!-- <policy domain="path" rights="none" pattern="@*"/> -->
142142
<!-- These image types are security risks on read, but write is fine -->
143-
<!-- <policy domain="coder" rights="write" pattern="{MSL,MVG,PS,SVG,URL,XPS}"/> -->
144143
<!-- <policy domain="module" rights="write" pattern="{MSL,MVG,PS,SVG,URL,XPS}"/> -->
145144
<!-- This policy sets the number of times to replace content of certain
146145
memory buffers and temporary files before they are freed or deleted. -->

config/policy-secure.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
<!-- Indirect reads are not permitted. -->
9494
<policy domain="path" rights="none" pattern="@*"/>
9595
<!-- These image types are security risks on read, but write is fine -->
96-
<policy domain="coder" rights="write" pattern="{MSL,MVG,PS,SVG,URL,XPS}"/>
9796
<policy domain="module" rights="write" pattern="{MSL,MVG,PS,SVG,URL,XPS}"/>
9897
<!-- This policy sets the number of times to replace content of certain
9998
memory buffers and temporary files before they are freed or deleted. -->

magick/constitute.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)