{
PolicyInfo
*p;
-
+
MagickBooleanType
status;
-
+
assert(exception != (ExceptionInfo *) NULL);
if (policy == (const char *) NULL)
return(MagickFalse);
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% SetMagickSecurityPolicyValue() sets the a value in the ImageMagick security
-% policy. It returns MagickFalse if the policy cannot be changed or if the
-% policy does not parse.
+% SetMagickSecurityPolicyValue() sets a value associated with an ImageMagick
+% security policy. For most policies, the value must be less than any value
+% set by the security policy configuration file (i.e. policy.xml). It returns
+% MagickFalse if the policy cannot be modified or if the policy does not parse.
%
% The format of the SetMagickSecurityPolicyValue method is:
%
register PolicyInfo
*p;
- register char
- *q;
-
status=MagickTrue;
LockSemaphoreInfo(policy_semaphore);
ResetLinkedListIterator(policy_cache);
{
case CachePolicyDomain:
{
- if (LocaleCompare(name,"synchronize") == 0)
- return(SetPolicyValue(domain,name,value));
if (LocaleCompare(name,"memory-map") == 0)
{
if (LocaleCompare(value,"anonymous") != 0)
ResetStreamAnonymousMemory();
return(SetPolicyValue(domain,name,value));
}
+ if (LocaleCompare(name,"synchronize") == 0)
+ return(SetPolicyValue(domain,name,value));
+ break;
}
- case SystemPolicyDomain:
+ case ResourcePolicyDomain:
{
- if (LocaleCompare(name,"precision") == 0)
+ ssize_t
+ type;
+
+ if (LocaleCompare(name,"temporary-path") == 0)
+ return(SetPolicyValue(domain,name,value));
+ type=ParseCommandOption(MagickResourceOptions,MagickFalse,name);
+ if (type >= 0)
{
- ResetMagickPrecision();
- return(SetPolicyValue(domain,name,value));
+ MagickSizeType
+ limit;
+
+ limit=MagickResourceInfinity;
+ if (LocaleCompare("unlimited",value) != 0)
+ limit=StringToMagickSizeType(value,100.0);
+ return(SetMagickResourceLimit((ResourceType) type,limit));
}
- if (LocaleCompare(name,"shred") == 0)
+ break;
+ }
+ case SystemPolicyDomain:
+ {
+ if (LocaleCompare(name,"max-memory-request") == 0)
{
- current_value=GetPolicyValue("system:shred");
+ current_value=GetPolicyValue("system:max-memory-request");
if ((current_value == (char *) NULL) ||
- (StringToInteger(value) > StringToInteger(current_value)))
- return(SetPolicyValue(domain,name,value));
+ (StringToSizeType(value,100.0) < StringToSizeType(current_value,100.0)))
+ {
+ ResetMaxMemoryRequest();
+ return(SetPolicyValue(domain,name,value));
+ }
}
- else if (LocaleCompare(name,"memory-map") == 0)
+ if (LocaleCompare(name,"memory-map") == 0)
{
if (LocaleCompare(value,"anonymous") != 0)
return(MagickFalse);
ResetVirtualAnonymousMemory();
return(SetPolicyValue(domain,name,value));
}
- else if (LocaleCompare(name,"max-memory-request") == 0)
+ if (LocaleCompare(name,"precision") == 0)
{
- current_value=GetPolicyValue("system:max-memory-request");
- if ((current_value == (char *) NULL) ||
- (StringToSizeType(value,100.0) < StringToSizeType(
- current_value,100.0)))
- {
- ResetMaxMemoryRequest();
- return(SetPolicyValue(domain,name,value));
- }
+ ResetMagickPrecision();
+ return(SetPolicyValue(domain,name,value));
}
- }
- case ResourcePolicyDomain:
- {
- if (LocaleCompare(name,"temporary-path") == 0)
- return(SetPolicyValue(domain,name,value));
- else
+ if (LocaleCompare(name,"shred") == 0)
{
- MagickSizeType
- limit;
-
- ResourceType
- type;
-
- type=(ResourceType) ParseCommandOption(MagickResourceOptions,
- MagickFalse,name);
- limit=MagickResourceInfinity;
- if (LocaleCompare("unlimited",value) != 0)
- limit=StringToMagickSizeType(value,100.0);
- return(SetMagickResourceLimit(type,limit));
- }
+ current_value=GetPolicyValue("system:shred");
+ if ((current_value == (char *) NULL) ||
+ (StringToInteger(value) > StringToInteger(current_value)))
+ return(SetPolicyValue(domain,name,value));
+ }
+ break;
}
- default:
case CoderPolicyDomain:
case DelegatePolicyDomain:
case FilterPolicyDomain:
case PathPolicyDomain:
+ default:
break;
}
return(MagickFalse);