Skip to content

Commit

Permalink
respect max-memory-request user policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristy committed Oct 25, 2023
1 parent 51d8bb2 commit e34171e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
3 changes: 2 additions & 1 deletion magick/memory-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ extern MagickPrivate MagickBooleanType

extern MagickPrivate void
ResetMaxMemoryRequest(void),
ResetVirtualAnonymousMemory(void);
ResetVirtualAnonymousMemory(void),
SetMaxMemoryRequest(const MagickSizeType);

#if defined(__cplusplus) || defined(c_plusplus)
}
Expand Down
27 changes: 27 additions & 0 deletions magick/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,33 @@ MagickExport void SetMagickMemoryMethods(
% %
% %
% %
+ S e t M a x M e m o r y R e q u e s t %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% SetMaxMemoryRequest() sets the max_memory_request value.
%
% The format of the ResetMaxMemoryRequest method is:
%
% void SetMaxMemoryRequest(const MagickSizeType limit)
%
% A description of each parameter follows:
%
% o limit: the maximum memory request limit.
%
*/
MagickPrivate void SetMaxMemoryRequest(const MagickSizeType limit)
{
max_memory_request=MagickMin(limit,GetMaxMemoryRequest());
}

/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% S h r e d F i l e %
% %
% %
Expand Down
8 changes: 7 additions & 1 deletion magick/policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1275,7 +1275,13 @@ static MagickBooleanType SetMagickSecurityPolicyValue(const PolicyDomain domain,
{
if (LocaleCompare(name,"max-memory-request") == 0)
{
ResetMaxMemoryRequest();
MagickSizeType
limit;

limit=MagickResourceInfinity;
if (LocaleCompare("unlimited",value) != 0)
limit=StringToMagickSizeType(value,100.0);
SetMaxMemoryRequest(limit);
return(MagickTrue);
}
if (LocaleCompare(name,"memory-map") == 0)
Expand Down

0 comments on commit e34171e

Please sign in to comment.