40#include "magick/studio.h"
41#include "magick/cache-private.h"
42#include "magick/client.h"
43#include "magick/configure.h"
44#include "magick/exception.h"
45#include "magick/exception-private.h"
46#include "magick/hashmap-private.h"
47#include "magick/locale_.h"
48#include "magick/magick-private.h"
49#include "magick/memory_.h"
50#include "magick/memory-private.h"
51#include "magick/monitor.h"
52#include "magick/monitor-private.h"
53#include "magick/option.h"
54#include "magick/policy.h"
55#include "magick/policy-private.h"
56#include "magick/resource_.h"
57#include "magick/semaphore.h"
58#include "magick/stream-private.h"
59#include "magick/string_.h"
60#include "magick/string-private.h"
61#include "magick/timer-private.h"
62#include "magick/token.h"
63#include "magick/utility.h"
64#include "magick/utility-private.h"
65#include "magick/xml-tree.h"
66#include "magick/xml-tree-private.h"
67#if defined(MAGICKCORE_XML_DELEGATE)
68# include <libxml/parser.h>
69# include <libxml/tree.h>
75#define PolicyFilename "policy.xml"
125static const PolicyMapInfo
128 { UndefinedPolicyDomain, UndefinedPolicyRights, (
const char *) NULL,
129 (
const char *) NULL, (
const char *) NULL }
133 *policy_cache = (LinkedListInfo *) NULL;
141static MagickBooleanType
142 IsPolicyCacheInstantiated(ExceptionInfo *),
143 LoadPolicyCache(LinkedListInfo *,
const char *,
const char *,
const size_t,
145 SetMagickSecurityPolicyValue(
const PolicyDomain,
const char *,
const char *,
174static LinkedListInfo *AcquirePolicyCache(
const char *filename,
175 ExceptionInfo *exception)
189 cache=NewLinkedList(0);
190 if (cache == (LinkedListInfo *) NULL)
191 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
193#if MAGICKCORE_ZERO_CONFIGURATION_SUPPORT
194 magick_unreferenced(filename);
195 status=LoadPolicyCache(cache,ZeroConfigurationPolicy,
"[zero-configuration]",0,
197 if (status == MagickFalse)
198 CatchException(exception);
207 options=GetConfigureOptions(filename,exception);
208 option=(
const StringInfo *) GetNextValueInLinkedList(options);
209 while (option != (
const StringInfo *) NULL)
211 status&=LoadPolicyCache(cache,(
const char *) GetStringInfoDatum(option),
212 GetStringInfoPath(option),0,exception);
213 if (status == MagickFalse)
214 CatchException(exception);
215 option=(
const StringInfo *) GetNextValueInLinkedList(options);
217 options=DestroyConfigureOptions(options);
223 for (i=0; i < (ssize_t) (
sizeof(PolicyMap)/
sizeof(*PolicyMap)); i++)
232 policy_info=(PolicyInfo *) AcquireMagickMemory(
sizeof(*policy_info));
233 if (policy_info == (PolicyInfo *) NULL)
235 (void) ThrowMagickException(exception,GetMagickModule(),
236 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
237 p->name == (
char *) NULL ?
"" : p->name);
238 CatchException(exception);
242 (void) memset(policy_info,0,
sizeof(*policy_info));
243 policy_info->path=(
char *)
"[built-in]";
244 policy_info->domain=p->domain;
245 policy_info->rights=p->rights;
246 policy_info->name=(
char *) p->name;
247 policy_info->pattern=(
char *) p->pattern;
248 policy_info->value=(
char *) p->value;
249 policy_info->exempt=MagickTrue;
250 policy_info->signature=MagickCoreSignature;
251 status&=AppendValueToLinkedList(cache,policy_info);
252 if (status == MagickFalse)
254 (void) ThrowMagickException(exception,GetMagickModule(),
255 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
256 p->name == (
char *) NULL ?
"" : p->name);
257 CatchException(exception);
260 if (status == MagickFalse)
261 CatchException(exception);
290static PolicyInfo *GetPolicyInfo(
const char *name,ExceptionInfo *exception)
293 policyname[MagickPathExtent],
305 assert(exception != (ExceptionInfo *) NULL);
306 if (IsPolicyCacheInstantiated(exception) == MagickFalse)
307 return((PolicyInfo *) NULL);
312 if (name != (
const char *) NULL)
313 (void) CopyMagickString(policyname,name,MagickPathExtent);
314 for (q=policyname; *q !=
'\0'; q++)
316 if (isspace((
int) ((
unsigned char) *q)) == 0)
318 (void) CopyMagickString(q,q+1,MagickPathExtent);
324 domain=UndefinedPolicyDomain;
325 for (q=policyname; *q !=
'\0'; q++)
330 domain=(PolicyDomain) ParseCommandOption(MagickPolicyDomainOptions,
331 MagickTrue,policyname);
332 (void) CopyMagickString(policyname,q+1,MagickPathExtent);
338 policy=(PolicyInfo *) NULL;
339 LockSemaphoreInfo(policy_semaphore);
340 ResetLinkedListIterator(policy_cache);
341 p=GetHeadElementInLinkedList(policy_cache);
342 if ((name == (
const char *) NULL) || (LocaleCompare(name,
"*") == 0))
344 UnlockSemaphoreInfo(policy_semaphore);
345 if (p != (ElementInfo *) NULL)
346 policy=(PolicyInfo *) p->value;
349 while (p != (ElementInfo *) NULL)
351 policy=(PolicyInfo *) p->value;
352 if ((domain == UndefinedPolicyDomain) || (policy->domain == domain))
353 if (LocaleCompare(policyname,policy->name) == 0)
357 if (p == (ElementInfo *) NULL)
358 policy=(PolicyInfo *) NULL;
360 (
void) SetHeadElementInLinkedList(policy_cache,p);
361 UnlockSemaphoreInfo(policy_semaphore);
392MagickExport
const PolicyInfo **GetPolicyInfoList(
const char *pattern,
393 size_t *number_policies,ExceptionInfo *exception)
407 assert(pattern != (
char *) NULL);
408 assert(number_policies != (
size_t *) NULL);
409 if (IsEventLogging() != MagickFalse)
410 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
412 p=GetPolicyInfo(
"*",exception);
413 if (p == (
const PolicyInfo *) NULL)
414 return((
const PolicyInfo **) NULL);
415 policies=(
const PolicyInfo **) AcquireQuantumMemory((
size_t)
416 GetNumberOfElementsInLinkedList(policy_cache)+1UL,
sizeof(*policies));
417 if (policies == (
const PolicyInfo **) NULL)
418 return((
const PolicyInfo **) NULL);
422 LockSemaphoreInfo(policy_semaphore);
423 ResetLinkedListIterator(policy_cache);
424 p=(
const PolicyInfo *) GetNextValueInLinkedList(policy_cache);
425 for (i=0; p != (
const PolicyInfo *) NULL; )
427 if ((p->stealth == MagickFalse) &&
428 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
430 p=(
const PolicyInfo *) GetNextValueInLinkedList(policy_cache);
432 UnlockSemaphoreInfo(policy_semaphore);
433 policies[i]=(PolicyInfo *) NULL;
434 *number_policies=(size_t) i;
466static char *AcquirePolicyString(
const char *source,
const size_t pad)
475 if (source != (
char *) NULL)
476 length+=strlen(source);
477 destination=(
char *) NULL;
479 destination=(
char *) AcquireMagickMemory((length+pad)*
sizeof(*destination));
480 if (destination == (
char *) NULL)
481 ThrowFatalException(ResourceLimitFatalError,
"UnableToAcquireString");
482 if (source != (
char *) NULL)
483 (void) memcpy(destination,source,length*
sizeof(*destination));
484 destination[length]=
'\0';
488MagickExport
char **GetPolicyList(
const char *pattern,
size_t *number_policies,
489 ExceptionInfo *exception)
503 assert(pattern != (
char *) NULL);
504 assert(number_policies != (
size_t *) NULL);
505 if (IsEventLogging() != MagickFalse)
506 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",pattern);
508 p=GetPolicyInfo(
"*",exception);
509 if (p == (
const PolicyInfo *) NULL)
510 return((
char **) NULL);
511 policies=(
char **) AcquireQuantumMemory((
size_t)
512 GetNumberOfElementsInLinkedList(policy_cache)+1UL,
sizeof(*policies));
513 if (policies == (
char **) NULL)
514 return((
char **) NULL);
518 LockSemaphoreInfo(policy_semaphore);
519 ResetLinkedListIterator(policy_cache);
520 p=(
const PolicyInfo *) GetNextValueInLinkedList(policy_cache);
521 for (i=0; p != (
const PolicyInfo *) NULL; )
523 if ((p->stealth == MagickFalse) &&
524 (GlobExpression(p->name,pattern,MagickFalse) != MagickFalse))
525 policies[i++]=AcquirePolicyString(p->name,1);
526 p=(
const PolicyInfo *) GetNextValueInLinkedList(policy_cache);
528 UnlockSemaphoreInfo(policy_semaphore);
529 policies[i]=(
char *) NULL;
530 *number_policies=(size_t) i;
556MagickExport
char *GetPolicyValue(
const char *name)
567 assert(name != (
const char *) NULL);
568 if (IsEventLogging() != MagickFalse)
569 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",name);
570 exception=AcquireExceptionInfo();
571 policy_info=GetPolicyInfo(name,exception);
572 exception=DestroyExceptionInfo(exception);
573 if (policy_info == (PolicyInfo *) NULL)
574 return((
char *) NULL);
575 value=policy_info->value;
576 if ((value == (
const char *) NULL) || (*value ==
'\0'))
577 return((
char *) NULL);
578 return(AcquirePolicyString(value,1));
604static MagickBooleanType IsPolicyCacheInstantiated(ExceptionInfo *exception)
606 if (policy_cache == (LinkedListInfo *) NULL)
608 GetMaxMemoryRequest();
610 ActivateSemaphoreInfo(&policy_semaphore);
611 LockSemaphoreInfo(policy_semaphore);
612 if (policy_cache == (LinkedListInfo *) NULL)
613 policy_cache=AcquirePolicyCache(PolicyFilename,exception);
614 UnlockSemaphoreInfo(policy_semaphore);
616 return(policy_cache != (LinkedListInfo *) NULL ? MagickTrue : MagickFalse);
648static inline MagickBooleanType ParseNamespace(
const char *qualified_pattern,
649 char **name,
char **pattern)
658 if ((qualified_pattern == (
const char *) NULL) || (name == (
char **) NULL) ||
659 (pattern == (
char **) NULL))
662 *pattern=(
char *) NULL;
663 separator=strstr(qualified_pattern,
"::");
664 if (separator == (
const char *) NULL)
666 *pattern=AcquireString(qualified_pattern);
667 return(*pattern != (
char *) NULL ? MagickTrue : MagickFalse);
669 length=(size_t) (separator-qualified_pattern);
670 *name=(
char *) AcquireQuantumMemory(length+1,
sizeof(
char));
671 if (*name == (
char *) NULL)
673 (void) CopyMagickString(*name,qualified_pattern,length+1);
675 *pattern=AcquireString(p);
676 if (*pattern == (
char *) NULL)
678 *name=DestroyString(*name);
685MagickExport MagickBooleanType IsRightsAuthorized(
const PolicyDomain domain,
686 const PolicyRights rights,
const char *qualified_pattern)
689 *name = (
char *) NULL,
690 *pattern = (
char *) NULL,
691 *real_pattern = (
char *) NULL;
694 **policies = (
const PolicyInfo **) NULL;
700 matched_any = MagickFalse;
703 effective_rights = AllPolicyRights;
711 if ((GetLogEventMask() & PolicyEvent) != 0)
712 (void) LogMagickEvent(PolicyEvent,GetMagickModule(),
713 "Domain: %s; rights=%s; pattern=\"%s\" ...",
714 CommandOptionToMnemonic(MagickPolicyDomainOptions,domain),
715 CommandOptionToMnemonic(MagickPolicyRightsOptions,rights),
720 exception=AcquireExceptionInfo();
721 policies=GetPolicyInfoList(
"*",&count,exception);
722 exception=DestroyExceptionInfo(exception);
723 if (policies == (
const PolicyInfo **) NULL)
725 if (ParseNamespace(qualified_pattern,&name,&pattern) == MagickFalse)
727 policies=(
const PolicyInfo **) RelinquishMagickMemory((
void *) policies);
733 for (i=0; i < (ssize_t) count; i++)
736 *policy = policies[i];
741 if (policy->domain != domain)
743 if ((name != (
char *) NULL) && (LocaleCompare(name,policy->name) != 0))
745 if ((policy->domain == PathPolicyDomain) &&
746 (real_pattern == (
const char *) NULL))
747 real_pattern=realpath_utf8(pattern);
748 match=GlobExpression(real_pattern != (
char*) NULL ? real_pattern : pattern,
749 policy->pattern,MagickFalse);
750 if (match == MagickFalse)
752 matched_any=MagickTrue;
753 effective_rights=policy->rights;
755 policies=(
const PolicyInfo **) RelinquishMagickMemory((
void *) policies);
756 if (pattern != (
char *) NULL)
757 pattern=DestroyString(pattern);
758 if (name != (
char *) NULL)
759 name=DestroyString(name);
760 if (real_pattern != (
char *) NULL)
761 real_pattern=DestroyString(real_pattern);
765 if (matched_any == MagickFalse)
767 if ((rights & ReadPolicyRights) &&
768 !(effective_rights & ReadPolicyRights))
770 if ((rights & WritePolicyRights) &&
771 !(effective_rights & WritePolicyRights))
773 if ((rights & ExecutePolicyRights) &&
774 !(effective_rights & ExecutePolicyRights))
803MagickExport MagickBooleanType ListPolicyInfo(FILE *file,
804 ExceptionInfo *exception)
822 if (file == (
const FILE *) NULL)
824 policy_info=GetPolicyInfoList(
"*",&number_policies,exception);
825 if (policy_info == (
const PolicyInfo **) NULL)
827 path=(
const char *) NULL;
828 for (i=0; i < (ssize_t) number_policies; i++)
830 if (policy_info[i]->stealth != MagickFalse)
832 if (((path == (
const char *) NULL) ||
833 (LocaleCompare(path,policy_info[i]->path) != 0)) &&
834 (policy_info[i]->path != (
char *) NULL))
835 (void) FormatLocaleFile(file,
"\nPath: %s\n",policy_info[i]->path);
836 path=policy_info[i]->path;
837 domain=CommandOptionToMnemonic(MagickPolicyDomainOptions,
838 policy_info[i]->domain);
839 (void) FormatLocaleFile(file,
" Policy: %s\n",domain);
840 if ((policy_info[i]->domain == CachePolicyDomain) ||
841 (policy_info[i]->domain == ResourcePolicyDomain) ||
842 (policy_info[i]->domain == SystemPolicyDomain))
844 if (policy_info[i]->name != (
char *) NULL)
845 (void) FormatLocaleFile(file,
" name: %s\n",policy_info[i]->name);
846 if (policy_info[i]->value != (
char *) NULL)
847 (void) FormatLocaleFile(file,
" value: %s\n",policy_info[i]->value);
851 (void) FormatLocaleFile(file,
" rights: ");
852 if (policy_info[i]->rights == NoPolicyRights)
853 (void) FormatLocaleFile(file,
"None ");
854 if ((policy_info[i]->rights & ReadPolicyRights) != 0)
855 (void) FormatLocaleFile(file,
"Read ");
856 if ((policy_info[i]->rights & WritePolicyRights) != 0)
857 (void) FormatLocaleFile(file,
"Write ");
858 if ((policy_info[i]->rights & ExecutePolicyRights) != 0)
859 (void) FormatLocaleFile(file,
"Execute ");
860 (void) FormatLocaleFile(file,
"\n");
861 if (policy_info[i]->pattern != (
char *) NULL)
862 (void) FormatLocaleFile(file,
" pattern: %s\n",
863 policy_info[i]->pattern);
866 policy_info=(
const PolicyInfo **) RelinquishMagickMemory((
void *)
902static MagickBooleanType LoadPolicyCache(LinkedListInfo *cache,
const char *xml,
903 const char *filename,
const size_t depth,ExceptionInfo *exception)
906 keyword[MagickPathExtent],
924 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
925 "Loading policy file \"%s\" ...",filename);
926 if (xml == (
char *) NULL)
929 policy_info=(PolicyInfo *) NULL;
930 token=AcquirePolicyString(xml,MagickPathExtent);
931 extent=strlen(token)+MagickPathExtent;
932 for (q=(
const char *) xml; *q !=
'\0'; )
937 (void) GetNextToken(q,&q,extent,token);
940 (void) CopyMagickString(keyword,token,MagickPathExtent);
941 if (LocaleNCompare(keyword,
"<!DOCTYPE",9) == 0)
946 while ((LocaleNCompare(q,
"]>",2) != 0) && (*q !=
'\0'))
947 (void) GetNextToken(q,&q,extent,token);
950 if (LocaleNCompare(keyword,
"<!--",4) == 0)
955 while ((LocaleNCompare(q,
"->",2) != 0) && (*q !=
'\0'))
956 (void) GetNextToken(q,&q,extent,token);
959 if (LocaleCompare(keyword,
"<include") == 0)
964 while (((*token !=
'/') && (*(token+1) !=
'>')) && (*q !=
'\0'))
966 (void) CopyMagickString(keyword,token,MagickPathExtent);
967 (void) GetNextToken(q,&q,extent,token);
970 (void) GetNextToken(q,&q,extent,token);
971 if (LocaleCompare(keyword,
"file") == 0)
973 if (depth > MagickMaxRecursionDepth)
974 (void) ThrowMagickException(exception,GetMagickModule(),
975 ConfigureError,
"IncludeElementNestedTooDeeply",
"`%s'",token);
979 path[MagickPathExtent],
982 GetPathComponent(filename,HeadPath,path);
984 (void) ConcatenateMagickString(path,DirectorySeparator,
986 if (*token == *DirectorySeparator)
987 (void) CopyMagickString(path,token,MagickPathExtent);
989 (
void) ConcatenateMagickString(path,token,MagickPathExtent);
990 xml=FileToXML(path,~0UL);
991 if (xml != (
char *) NULL)
993 status&=LoadPolicyCache(cache,xml,path,depth+1,
995 xml=(
char *) RelinquishMagickMemory(xml);
1002 if (LocaleCompare(keyword,
"<policy") == 0)
1007 policy_info=(PolicyInfo *) AcquireMagickMemory(
sizeof(*policy_info));
1008 if (policy_info == (PolicyInfo *) NULL)
1009 ThrowFatalException(ResourceLimitFatalError,
"MemoryAllocationFailed");
1010 (void) memset(policy_info,0,
sizeof(*policy_info));
1011 policy_info->path=AcquirePolicyString(filename,1);
1012 policy_info->exempt=MagickFalse;
1013 policy_info->signature=MagickCoreSignature;
1016 if (policy_info == (PolicyInfo *) NULL)
1018 if ((LocaleCompare(keyword,
"/>") == 0) ||
1019 (LocaleCompare(keyword,
"</policy>") == 0))
1021 status=AppendValueToLinkedList(cache,policy_info);
1022 if (status == MagickFalse)
1023 (void) ThrowMagickException(exception,GetMagickModule(),
1024 ResourceLimitError,
"MemoryAllocationFailed",
"`%s'",
1026 policy_info=(PolicyInfo *) NULL;
1029 (void) GetNextToken(q,(
const char **) NULL,extent,token);
1032 (void) GetNextToken(q,&q,extent,token);
1033 (void) GetNextToken(q,&q,extent,token);
1039 if (LocaleCompare((
char *) keyword,
"domain") == 0)
1041 policy_info->domain=(PolicyDomain) ParseCommandOption(
1042 MagickPolicyDomainOptions,MagickTrue,token);
1050 if (LocaleCompare((
char *) keyword,
"name") == 0)
1052 policy_info->name=AcquirePolicyString(token,1);
1060 if (LocaleCompare((
char *) keyword,
"pattern") == 0)
1062 policy_info->pattern=AcquirePolicyString(token,1);
1070 if (LocaleCompare((
char *) keyword,
"rights") == 0)
1072 policy_info->rights=(PolicyRights) ParseCommandOption(
1073 MagickPolicyRightsOptions,MagickTrue,token);
1081 if (LocaleCompare((
char *) keyword,
"stealth") == 0)
1083 policy_info->stealth=IsMagickTrue(token);
1091 if (LocaleCompare((
char *) keyword,
"value") == 0)
1093 policy_info->value=AcquirePolicyString(token,1);
1102 token=(
char *) RelinquishMagickMemory(token);
1103 if (status == MagickFalse)
1104 CatchException(exception);
1105 return(status != 0 ? MagickTrue : MagickFalse);
1126MagickExport MagickBooleanType PolicyComponentGenesis(
void)
1129 policy_semaphore=AllocateSemaphoreInfo();
1152static void *DestroyPolicyElement(
void *policy_info)
1157 p=(PolicyInfo *) policy_info;
1158 if (p->exempt == MagickFalse)
1160 if (p->value != (
char *) NULL)
1161 p->value=DestroyString(p->value);
1162 if (p->pattern != (
char *) NULL)
1163 p->pattern=DestroyString(p->pattern);
1164 if (p->name != (
char *) NULL)
1165 p->name=DestroyString(p->name);
1166 if (p->path != (
char *) NULL)
1167 p->path=DestroyString(p->path);
1169 p=(PolicyInfo *) RelinquishMagickMemory(p);
1170 return((
void *) NULL);
1173MagickExport
void PolicyComponentTerminus(
void)
1176 ActivateSemaphoreInfo(&policy_semaphore);
1177 LockSemaphoreInfo(policy_semaphore);
1178 if (policy_cache != (LinkedListInfo *) NULL)
1179 policy_cache=DestroyLinkedList(policy_cache,DestroyPolicyElement);
1180 UnlockSemaphoreInfo(policy_semaphore);
1181 DestroySemaphoreInfo(&policy_semaphore);
1211static MagickBooleanType ValidateSecurityPolicy(
const char *policy,
1212 const char *url,ExceptionInfo *exception)
1214#if defined(MAGICKCORE_XML_DELEGATE)
1221 document=xmlReadMemory(policy,(
int) strlen(policy),url,NULL,
1222 XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
1223 if (document == (xmlDocPtr) NULL)
1225 (void) ThrowMagickException(exception,GetMagickModule(),ConfigureError,
1226 "PolicyValidationException",
"'%s'",url);
1227 return(MagickFalse);
1229 xmlFreeDoc(document);
1238MagickExport MagickBooleanType SetMagickSecurityPolicy(
const char *policy,
1239 ExceptionInfo *exception)
1253 assert(exception != (ExceptionInfo *) NULL);
1254 if (policy == (
const char *) NULL)
1255 return(MagickFalse);
1256 if (ValidateSecurityPolicy(policy,PolicyFilename,exception) == MagickFalse)
1257 return(MagickFalse);
1258 status=LoadPolicyCache(policy_cache,policy,
"[user-policy]",0,exception);
1259 if (status == MagickFalse)
1264 user_policies=NewLinkedList(0);
1265 status=LoadPolicyCache(user_policies,policy,
"[user-policy]",0,exception);
1266 if (status == MagickFalse)
1268 user_policies=DestroyLinkedList(user_policies,DestroyPolicyElement);
1269 return(MagickFalse);
1271 ResetLinkedListIterator(user_policies);
1272 p=(PolicyInfo *) GetNextValueInLinkedList(user_policies);
1273 while (p != (PolicyInfo *) NULL)
1275 if ((p->name != (
char *) NULL) && (p->value != (
char *) NULL))
1276 (void) SetMagickSecurityPolicyValue(p->domain,p->name,p->value,exception);
1277 p=(PolicyInfo *) GetNextValueInLinkedList(user_policies);
1279 user_policies=DestroyLinkedList(user_policies,DestroyPolicyElement);
1316static MagickBooleanType SetMagickSecurityPolicyValue(
const PolicyDomain domain,
1317 const char *name,
const char *value,ExceptionInfo *exception)
1319 magick_unreferenced(exception);
1320 assert(exception != (ExceptionInfo *) NULL);
1321 if ((name == (
const char *) NULL) || (value == (
const char *) NULL))
1322 return(MagickFalse);
1325 case CachePolicyDomain:
1327 if (LocaleCompare(name,
"memory-map") == 0)
1329 if (LocaleCompare(value,
"anonymous") != 0)
1330 return(MagickFalse);
1331 ResetCacheAnonymousMemory();
1332 ResetStreamAnonymousMemory();
1337 case ResourcePolicyDomain:
1342 type=ParseCommandOption(MagickResourceOptions,MagickFalse,name);
1348 limit=MagickResourceInfinity;
1349 if (LocaleCompare(
"unlimited",value) != 0)
1350 limit=StringToMagickSizeType(value,100.0);
1351 if ((ResourceType) type == TimeResource)
1352 limit=(MagickSizeType) ParseMagickTimeToLive(value);
1353 return(SetMagickResourceLimit((ResourceType) type,limit));
1357 case SystemPolicyDomain:
1359 if (LocaleCompare(name,
"max-memory-request") == 0)
1364 limit=MagickResourceInfinity;
1365 if (LocaleCompare(
"unlimited",value) != 0)
1366 limit=StringToMagickSizeType(value,100.0);
1367 SetMaxMemoryRequest(limit);
1370 if (LocaleCompare(name,
"memory-map") == 0)
1372 if (LocaleCompare(value,
"anonymous") != 0)
1373 return(MagickFalse);
1374 ResetVirtualAnonymousMemory();
1377 if (LocaleCompare(name,
"precision") == 0)
1382 limit=StringToInteger(value);
1383 SetMagickPrecision(limit);
1388 case CoderPolicyDomain:
1389 case DelegatePolicyDomain:
1390 case FilterPolicyDomain:
1391 case ModulePolicyDomain:
1392 case PathPolicyDomain:
1396 return(MagickFalse);