]> granicus.if.org Git - imagemagick/commitdiff
Added SetMagickSecurityPolicyValue that can be used to change a security policy value.
authorDirk Lemstra <dirk@git.imagemagick.org>
Sat, 13 Jan 2018 23:15:19 +0000 (00:15 +0100)
committerDirk Lemstra <dirk@git.imagemagick.org>
Sat, 13 Jan 2018 23:15:19 +0000 (00:15 +0100)
12 files changed:
MagickCore/cache-private.h
MagickCore/cache.c
MagickCore/magick-private.h
MagickCore/magick.c
MagickCore/memory-private.h
MagickCore/memory.c
MagickCore/policy.c
MagickCore/policy.h
MagickCore/resource.c
MagickCore/stream-private.h
MagickCore/stream.c
MagickCore/string-private.h

index 556bb75ba60d9a2ddf0015546758b39d779d35c7..e7d66c79d827f8edd87ed4705f99cb5462adc00c 100644 (file)
@@ -280,6 +280,7 @@ extern MagickPrivate void
   ClonePixelCacheMethods(Cache,const Cache),
   GetPixelCacheTileSize(const Image *,size_t *,size_t *),
   GetPixelCacheMethods(CacheMethods *),
+  ResetCacheAnonymousMemory(void),
   ResetPixelCacheEpoch(void),
   ResetPixelCacheChannels(Image *),
   SetPixelCacheMethods(Cache,CacheMethods *);
index b3b96040d934c91e972ba8dcfe1451d9bf340134..b27850345d2fc098919f6c96d10eaa44844498d7 100644 (file)
@@ -4579,6 +4579,29 @@ MagickPrivate void ResetPixelCacheChannels(Image *image)
 %                                                                             %
 %                                                                             %
 %                                                                             %
++   R e s e t C a c h e A n o n y m o u s M e m o r y                         %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ResetCacheAnonymousMemory() resets the anonymous_memory value.
+%
+%  The format of the ResetCacheAnonymousMemory method is:
+%
+%      void ResetCacheAnonymousMemory(void)
+%
+*/
+MagickPrivate void ResetCacheAnonymousMemory(void)
+{
+  cache_anonymous_memory=0;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 +   R e s e t P i x e l C a c h e E p o c h                                   %
 %                                                                             %
 %                                                                             %
index daec8b3503fa1920925730b7bdd1f0b9dcc317f8..f1464c02dc16f7b4fc0f9e1caba7b29a93044ce8 100644 (file)
@@ -27,7 +27,8 @@ extern MagickPrivate MagickBooleanType
   MagickComponentGenesis(void);
 
 extern MagickPrivate void
-  MagickComponentTerminus(void);
+  MagickComponentTerminus(void),
+  ResetMagickPrecision(void);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index 8b2fd8c27d4f4946930a5a83caefa2a63dfb7cf7..3c110b2f84f4f792f7e4d3a3f52cbcfaf31d3a71 100644 (file)
@@ -128,6 +128,9 @@ static volatile MagickBooleanType
   instantiate_magickcore = MagickFalse,
   magickcore_signal_in_progress = MagickFalse,
   magick_list_initialized = MagickFalse;
+
+static int
+  magick_precision = 0;
 \f
 /*
   Forward declarations.
@@ -1631,6 +1634,29 @@ MagickExport MagickBooleanType RegisterMagickInfo(MagickInfo *magick_info)
 %                                                                             %
 %                                                                             %
 %                                                                             %
++   R e s e t M a g i c k P r e c i s i o n                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ResetMagickPrecision() resets the magick_precision value.
+%
+%  The format of the ResetMagickPrecision method is:
+%
+%      void ResetMagickPrecision(void)
+%
+*/
+MagickPrivate void ResetMagickPrecision(void)
+{
+  magick_precision=0;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   S e t M a g i c k P r e c i s i o n                                       %
 %                                                                             %
 %                                                                             %
@@ -1659,9 +1685,6 @@ MagickExport int SetMagickPrecision(const int precision)
 {
 #define MagickPrecision  6
 
-  static int
-    magick_precision = 0;
-
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   if (precision > 0)
     magick_precision=precision;
index 36eb82623bc6c740fb4c1f0da6b1feb1cf7b18fb..4c524b0f73f4c064421131cda430cca8ea10e323 100644 (file)
@@ -46,6 +46,10 @@ extern "C" {
 MagickExport MagickBooleanType 
   HeapOverflowSanityCheck(const size_t,const size_t) magick_alloc_sizes(1,2);
 
+extern MagickPrivate void
+  ResetMaxMemoryRequest(void),
+  ResetVirtualAnonymousMemory(void);
+
 static inline void *AcquireCriticalMemory(const size_t size)
 {
   register void
index aaa628b5021c2e7303665dbe6bc1797b796cfd6f..8a8556ba58f7d44912e57b643bf36b0a145a625e 100644 (file)
@@ -165,6 +165,10 @@ typedef struct _MemoryPool
 /*
   Global declarations.
 */
+static size_t
+  max_memory_request = 0,
+  virtual_anonymous_memory = 0;
+
 #if defined _MSC_VER
 static void* MSCMalloc(size_t size)
 {
@@ -564,17 +568,6 @@ MagickExport void *AcquireQuantumMemory(const size_t count,const size_t quantum)
 %
 */
 
-static inline size_t StringToSizeType(const char *string,const double interval)
-{
-  double
-    value;
-
-  value=SiPrefixToDoubleInterval(string,interval);
-  if (value >= (double) MagickULLConstant(~0))
-    return((size_t) MagickULLConstant(~0));
-  return((size_t) value);
-}
-
 MagickExport MemoryInfo *AcquireVirtualMemory(const size_t count,
   const size_t quantum)
 {
@@ -587,10 +580,6 @@ MagickExport MemoryInfo *AcquireVirtualMemory(const size_t count,
   size_t
     extent;
 
-  static size_t
-    max_memory_request = 0,
-    virtual_anonymous_memory = 0;
-
   if (HeapOverflowSanityCheck(count,quantum) != MagickFalse)
     return((MemoryInfo *) NULL);
   if (max_memory_request == 0)
@@ -1172,6 +1161,52 @@ MagickExport void *ResetMagickMemory(void *memory,int byte,const size_t size)
 %                                                                             %
 %                                                                             %
 %                                                                             %
++   R e s e t M a x M e m o r y R e q u e s t                                 %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ResetMaxMemoryRequest() resets the anonymous_memory value.
+%
+%  The format of the ResetMaxMemoryRequest method is:
+%
+%      void ResetMaxMemoryRequest(void)
+%
+*/
+MagickPrivate void ResetMaxMemoryRequest(void)
+{
+  max_memory_request=0;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
++   R e s e t V i r t u a l A n o n y m o u s M e m o r y                     %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ResetVirtualAnonymousMemory() resets the anonymous_memory value.
+%
+%  The format of the ResetVirtualAnonymousMemory method is:
+%
+%      void ResetVirtualAnonymousMemory(void)
+%
+*/
+MagickPrivate void ResetVirtualAnonymousMemory(void)
+{
+  virtual_anonymous_memory=0;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   R e s i z e M a g i c k M e m o r y                                       %
 %                                                                             %
 %                                                                             %
index bdc7e998fca987591f544ee4bca84e995e901d8e..3d5fdb646c40013ee88d3758470f3b4609d051fb 100644 (file)
   Include declarations.
 */
 #include "MagickCore/studio.h"
+#include "MagickCore/cache-private.h"
 #include "MagickCore/client.h"
 #include "MagickCore/configure.h"
 #include "MagickCore/configure-private.h"
 #include "MagickCore/exception.h"
 #include "MagickCore/exception-private.h"
+#include "MagickCore/magick-private.h"
 #include "MagickCore/memory_.h"
 #include "MagickCore/memory-private.h"
 #include "MagickCore/monitor.h"
 #include "MagickCore/option.h"
 #include "MagickCore/policy.h"
 #include "MagickCore/policy-private.h"
+#include "MagickCore/resource_.h"
 #include "MagickCore/resource-private.h"
 #include "MagickCore/semaphore.h"
+#include "MagickCore/stream-private.h"
 #include "MagickCore/string_.h"
+#include "MagickCore/string-private.h"
 #include "MagickCore/token.h"
 #include "MagickCore/utility.h"
 #include "MagickCore/utility-private.h"
@@ -494,7 +499,7 @@ MagickExport char **GetPolicyList(const char *pattern,
 %
 %  A description of each parameter follows:
 %
-%    o policy_info:  The policy info.
+%    o name:  The name of the policy.
 %
 */
 MagickExport char *GetPolicyValue(const char *name)
@@ -1090,3 +1095,168 @@ MagickExport MagickBooleanType SetMagickSecurityPolicy(const char *policy,
     return(MagickFalse);
   return(ResourceComponentGenesis());
 }
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%  S e t M a g i c k S e c u r i t y P o l i c y V a l u e                    %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  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.
+%
+%  The format of the SetMagickSecurityPolicyValue method is:
+%
+%      MagickBooleanType SetMagickSecurityPolicyValue(
+%        const PolicyDomain domain,const char *name,const char *value,
+%        ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o domain: the domain of the policy (e.g. system, resource).
+%
+%    o name: the name of the policy.
+%
+%    o value: the value to set the policy to.
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+
+static MagickBooleanType SetPolicyValue(const PolicyDomain domain,
+  const char *name,const char *value)
+{
+  MagickBooleanType
+    status;
+
+  register PolicyInfo
+    *p;
+
+  register char
+    *q;
+
+  status=MagickTrue;
+  LockSemaphoreInfo(policy_semaphore);
+  ResetLinkedListIterator(policy_cache);
+  p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache);
+  while (p != (PolicyInfo *) NULL)
+  {
+    if ((p->domain == domain) && (LocaleCompare(name,p->name) == 0))
+      break;
+    p=(PolicyInfo *) GetNextValueInLinkedList(policy_cache);
+  }
+  if (p != (PolicyInfo *) NULL)
+    {
+      if (p->value != (char *) NULL)
+        p->value=DestroyString(p->value);
+    }
+  else
+    {
+      p=(PolicyInfo *) AcquireCriticalMemory(sizeof(*p));
+      (void) ResetMagickMemory(p,0,sizeof(*p));
+      p->exempt=MagickFalse;
+      p->signature=MagickCoreSignature;
+      p->name=ConstantString(name);
+      status=AppendValueToLinkedList(policy_cache,p);
+    }
+  p->value=ConstantString(value);
+  UnlockSemaphoreInfo(policy_semaphore);
+  if (status == MagickFalse)
+    p=(PolicyInfo *) RelinquishMagickMemory(p);
+  return(status);
+}
+
+MagickExport MagickBooleanType SetMagickSecurityPolicyValue(
+  const PolicyDomain domain,const char *name,const char *value,
+  ExceptionInfo *exception)
+{
+  char
+    *current_value;
+
+  magick_unreferenced(exception);
+  assert(exception != (ExceptionInfo *) NULL);
+  if ((name == (const char *) NULL) || (value == (const char *) NULL))
+    return(MagickFalse);
+  switch(domain)
+  {
+    case CachePolicyDomain:
+    {
+      if (LocaleCompare(name,"synchronize") == 0)
+        return(SetPolicyValue(domain,name,value));
+      if (LocaleCompare(name,"memory-map") == 0)
+        {
+          if (LocaleCompare(value,"anonymous") != 0)
+            return(MagickFalse);
+          ResetCacheAnonymousMemory();
+          ResetStreamAnonymousMemory();
+          return(SetPolicyValue(domain,name,value));
+        }
+    }
+    case SystemPolicyDomain:
+    {
+      if (LocaleCompare(name,"precision") == 0)
+        {
+          ResetMagickPrecision();
+          return(SetPolicyValue(domain,name,value));
+        }
+      if (LocaleCompare(name,"shred") == 0)
+        {
+          current_value=GetPolicyValue("system:shred");
+          if ((current_value == (char *) NULL) ||
+              (StringToInteger(value) > StringToInteger(current_value)))
+            return(SetPolicyValue(domain,name,value));
+        }
+      else 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)
+        {
+          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));
+            }
+        }
+    }
+    case ResourcePolicyDomain:
+    {
+      if (LocaleCompare(name,"temporary-path") == 0)
+        return(SetPolicyValue(domain,name,value));
+      else
+        {
+          MagickSizeType
+            limit;
+
+          ResourceType
+            type;
+
+          type=(ResourceType) ParseCommandOption(MagickResourceOptions,
+            MagickFalse,value);
+          limit=MagickResourceInfinity;
+          if (LocaleCompare("unlimited",value) != 0)
+            limit=StringToMagickSizeType(value,100.0);
+          return(SetMagickResourceLimit(type,limit));
+      }
+    }
+    default:
+    case CoderPolicyDomain:
+    case DelegatePolicyDomain:
+    case FilterPolicyDomain:
+    case PathPolicyDomain:
+      break;
+  }
+  return(MagickFalse);
+}
index 418d1aa06427cedede65253b42db3d2619a2af20..c29af372b610f6428c089babc9a75ad75e5647c2 100644 (file)
@@ -60,7 +60,9 @@ extern MagickExport const PolicyInfo
 extern MagickExport MagickBooleanType
   IsRightsAuthorized(const PolicyDomain,const PolicyRights,const char *),
   ListPolicyInfo(FILE *,ExceptionInfo *),
-  SetMagickSecurityPolicy(const char *,ExceptionInfo *);
+  SetMagickSecurityPolicy(const char *,ExceptionInfo *),
+  SetMagickSecurityPolicyValue(const PolicyDomain,const char *,const char *,
+    ExceptionInfo *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }
index 078b44263f084191109aaf65bbd01ab1c6a35370..650e967e0059c77feb4eaf2ea0d6aa016cc84bf8 100644 (file)
@@ -1172,18 +1172,6 @@ MagickExport MagickBooleanType RelinquishUniqueFileResource(const char *path)
 %
 */
 
-static inline MagickSizeType StringToSizeType(const char *string,
-  const double interval)
-{
-  double
-    value;
-
-  value=SiPrefixToDoubleInterval(string,interval);
-  if (value >= (double) MagickULLConstant(~0))
-    return(MagickULLConstant(~0));
-  return((MagickSizeType) value);
-}
-
 MagickPrivate MagickBooleanType ResourceComponentGenesis(void)
 {
   char
@@ -1206,7 +1194,7 @@ MagickPrivate MagickBooleanType ResourceComponentGenesis(void)
   limit=GetEnvironmentValue("MAGICK_WIDTH_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(WidthResource,StringToSizeType(limit,
+      (void) SetMagickResourceLimit(WidthResource,StringToMagickSizeType(limit,
         100.0));
       limit=DestroyString(limit);
     }
@@ -1214,8 +1202,8 @@ MagickPrivate MagickBooleanType ResourceComponentGenesis(void)
   limit=GetEnvironmentValue("MAGICK_HEIGHT_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(HeightResource,StringToSizeType(limit,
-        100.0));
+      (void) SetMagickResourceLimit(HeightResource,StringToMagickSizeType(
+        limit,100.0));
       limit=DestroyString(limit);
     }
   pagesize=GetMagickPageSize();
@@ -1233,29 +1221,32 @@ MagickPrivate MagickBooleanType ResourceComponentGenesis(void)
   limit=GetEnvironmentValue("MAGICK_AREA_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(AreaResource,StringToSizeType(limit,100.0));
+      (void) SetMagickResourceLimit(AreaResource,StringToMagickSizeType(limit,
+        100.0));
       limit=DestroyString(limit);
     }
   (void) SetMagickResourceLimit(MemoryResource,memory);
   limit=GetEnvironmentValue("MAGICK_MEMORY_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(MemoryResource,
-        StringToSizeType(limit,100.0));
+      (void) SetMagickResourceLimit(MemoryResource,StringToMagickSizeType(
+        limit,100.0));
       limit=DestroyString(limit);
     }
   (void) SetMagickResourceLimit(MapResource,2*memory);
   limit=GetEnvironmentValue("MAGICK_MAP_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(MapResource,StringToSizeType(limit,100.0));
+      (void) SetMagickResourceLimit(MapResource,StringToMagickSizeType(limit,
+        100.0));
       limit=DestroyString(limit);
     }
   (void) SetMagickResourceLimit(DiskResource,MagickResourceInfinity);
   limit=GetEnvironmentValue("MAGICK_DISK_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(DiskResource,StringToSizeType(limit,100.0));
+      (void) SetMagickResourceLimit(DiskResource,StringToMagickSizeType(limit,
+        100.0));
       limit=DestroyString(limit);
     }
   files=(-1);
@@ -1283,7 +1274,7 @@ MagickPrivate MagickBooleanType ResourceComponentGenesis(void)
   limit=GetEnvironmentValue("MAGICK_FILE_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(FileResource,StringToSizeType(limit,
+      (void) SetMagickResourceLimit(FileResource,StringToMagickSizeType(limit,
         100.0));
       limit=DestroyString(limit);
     }
@@ -1291,23 +1282,24 @@ MagickPrivate MagickBooleanType ResourceComponentGenesis(void)
   limit=GetEnvironmentValue("MAGICK_THREAD_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(ThreadResource,StringToSizeType(limit,
-        100.0));
+      (void) SetMagickResourceLimit(ThreadResource,StringToMagickSizeType(
+        limit,100.0));
       limit=DestroyString(limit);
     }
   (void) SetMagickResourceLimit(ThrottleResource,0);
   limit=GetEnvironmentValue("MAGICK_THROTTLE_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(ThrottleResource,StringToSizeType(limit,
-        100.0));
+      (void) SetMagickResourceLimit(ThrottleResource,StringToMagickSizeType(
+        limit,100.0));
       limit=DestroyString(limit);
     }
   (void) SetMagickResourceLimit(TimeResource,MagickResourceInfinity);
   limit=GetEnvironmentValue("MAGICK_TIME_LIMIT");
   if (limit != (char *) NULL)
     {
-      (void) SetMagickResourceLimit(TimeResource,StringToSizeType(limit,100.0));
+      (void) SetMagickResourceLimit(TimeResource,StringToMagickSizeType(limit,
+        100.0));
       limit=DestroyString(limit);
     }
   return(MagickTrue);
@@ -1391,7 +1383,7 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.width_limit=limit;
       value=GetPolicyValue("resource:width");
       if (value != (char *) NULL)
-        resource_info.width_limit=MagickMin(limit,StringToSizeType(value,
+        resource_info.width_limit=MagickMin(limit,StringToMagickSizeType(value,
           100.0));
       break;
     }
@@ -1400,8 +1392,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.height_limit=limit;
       value=GetPolicyValue("resource:height");
       if (value != (char *) NULL)
-        resource_info.height_limit=MagickMin(limit,StringToSizeType(value,
-          100.0));
+        resource_info.height_limit=MagickMin(limit,StringToMagickSizeType(
+          value,100.0));
       break;
     }
     case AreaResource:
@@ -1409,7 +1401,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.area_limit=limit;
       value=GetPolicyValue("resource:area");
       if (value != (char *) NULL)
-        resource_info.area_limit=MagickMin(limit,StringToSizeType(value,100.0));
+        resource_info.area_limit=MagickMin(limit,StringToMagickSizeType(value,
+          100.0));
       break;
     }
     case MemoryResource:
@@ -1417,8 +1410,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.memory_limit=limit;
       value=GetPolicyValue("resource:memory");
       if (value != (char *) NULL)
-        resource_info.memory_limit=MagickMin(limit,StringToSizeType(value,
-          100.0));
+        resource_info.memory_limit=MagickMin(limit,StringToMagickSizeType(
+          value,100.0));
       break;
     }
     case MapResource:
@@ -1426,7 +1419,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.map_limit=limit;
       value=GetPolicyValue("resource:map");
       if (value != (char *) NULL)
-        resource_info.map_limit=MagickMin(limit,StringToSizeType(value,100.0));
+        resource_info.map_limit=MagickMin(limit,StringToMagickSizeType(value,
+          100.0));
       break;
     }
     case DiskResource:
@@ -1434,7 +1428,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.disk_limit=limit;
       value=GetPolicyValue("resource:disk");
       if (value != (char *) NULL)
-        resource_info.disk_limit=MagickMin(limit,StringToSizeType(value,100.0));
+        resource_info.disk_limit=MagickMin(limit,StringToMagickSizeType(value,
+          100.0));
       break;
     }
     case FileResource:
@@ -1442,7 +1437,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.file_limit=limit;
       value=GetPolicyValue("resource:file");
       if (value != (char *) NULL)
-        resource_info.file_limit=MagickMin(limit,StringToSizeType(value,100.0));
+        resource_info.file_limit=MagickMin(limit,StringToMagickSizeType(value,
+          100.0));
       break;
     }
     case ThreadResource:
@@ -1450,8 +1446,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.thread_limit=limit;
       value=GetPolicyValue("resource:thread");
       if (value != (char *) NULL)
-        resource_info.thread_limit=MagickMin(limit,StringToSizeType(value,
-          100.0));
+        resource_info.thread_limit=MagickMin(limit,StringToMagickSizeType(
+          value,100.0));
       if (resource_info.thread_limit > GetOpenMPMaximumThreads())
         resource_info.thread_limit=GetOpenMPMaximumThreads();
       else
@@ -1464,8 +1460,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.throttle_limit=limit;
       value=GetPolicyValue("resource:throttle");
       if (value != (char *) NULL)
-        resource_info.throttle_limit=MagickMax(limit,StringToSizeType(value,
-          100.0));
+        resource_info.throttle_limit=MagickMax(limit,StringToMagickSizeType(
+          value,100.0));
       break;
     }
     case TimeResource:
@@ -1473,7 +1469,8 @@ MagickExport MagickBooleanType SetMagickResourceLimit(const ResourceType type,
       resource_info.time_limit=limit;
       value=GetPolicyValue("resource:time");
       if (value != (char *) NULL)
-        resource_info.time_limit=MagickMin(limit,StringToSizeType(value,100.0));
+        resource_info.time_limit=MagickMin(limit,StringToMagickSizeType(value,
+          100.0));
       ResetPixelCacheEpoch();
       break;
     }
index 41b9ed875b820fffdd2846a66f277e0908a8fc59..6a72210084f04c98ab591aa51164fc8c32b432bc 100644 (file)
@@ -26,6 +26,7 @@ extern MagickPrivate const void
   *GetStreamInfoClientData(StreamInfo *);
 
 extern MagickPrivate void
+  ResetStreamAnonymousMemory(void),
   SetStreamInfoClientData(StreamInfo *,const void *);
 
 #if defined(__cplusplus) || defined(c_plusplus)
index 0ccd9678e921a1cc01c3be5765b4ef7f5873e07c..c0f5553f6a8e24b368da7485c8a6d5d8042c16bc 100644 (file)
@@ -1055,6 +1055,29 @@ MagickExport Image *ReadStream(const ImageInfo *image_info,StreamHandler stream,
 %                                                                             %
 %                                                                             %
 %                                                                             %
++   R e s e t S t r e a m A n o n y m o u s M e m o r y                       %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ResetStreamAnonymousMemory() resets the anonymous_memory value.
+%
+%  The format of the ResetStreamAnonymousMemory method is:
+%
+%      void ResetStreamAnonymousMemory(void)
+%
+*/
+MagickPrivate void ResetStreamAnonymousMemory(void)
+{
+  cache_anonymous_memory=0;
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 +   S e t S t r e a m I n f o C l i e n t D a t a                             %
 %                                                                             %
 %                                                                             %
index b077f7ed25081582051ec368b1dc17f567ff36e2..7127a39e6a76cf10ccdc39af72b00df4cd0d4556 100644 (file)
@@ -70,6 +70,30 @@ static inline long StringToLong(const char *magick_restrict value)
   return(strtol(value,(char **) NULL,10));
 }
 
+static inline MagickSizeType StringToMagickSizeType(const char *string,
+  const double interval)
+{
+  double
+    value;
+
+  value=SiPrefixToDoubleInterval(string,interval);
+  if (value >= (double) MagickULLConstant(~0))
+    return(MagickULLConstant(~0));
+  return((MagickSizeType) value);
+}
+
+static inline size_t StringToSizeType(const char *string,
+  const double interval)
+{
+  double
+    value;
+
+  value=SiPrefixToDoubleInterval(string,interval);
+  if (value >= (double) MagickULLConstant(~0))
+    return((size_t) MagickULLConstant(~0));
+  return((size_t) value);
+}
+
 static inline unsigned long StringToUnsignedLong(
   const char *magick_restrict value)
 {