Magick++/lib/Options.cpp \
Magick++/lib/Pixels.cpp \
Magick++/lib/ResourceLimits.cpp \
+ Magick++/lib/SecurityPolicy.cpp \
Magick++/lib/Statistic.cpp \
Magick++/lib/STL.cpp \
Magick++/lib/Thread.cpp \
Magick++/lib/Magick++/Options.h \
Magick++/lib/Magick++/Pixels.h \
Magick++/lib/Magick++/ResourceLimits.h \
+ Magick++/lib/Magick++/SecurityPolicy.h \
Magick++/lib/Magick++/Statistic.h \
Magick++/lib/Magick++/STL.h \
Magick++/lib/Magick++/Thread.h \
Magick++/lib/Magick++/Montage.h \
Magick++/lib/Magick++/Pixels.h \
Magick++/lib/Magick++/ResourceLimits.h \
+ Magick++/lib/Magick++/SecurityPolicy.h \
Magick++/lib/Magick++/Statistic.h \
Magick++/lib/Magick++/STL.h \
Magick++/lib/Magick++/TypeMetric.h
#include <Magick++/ResourceLimits.h>
+#include <Magick++/SecurityPolicy.h>
class FuzzingLimits {
public:
FuzzingLimits() {
+ Magick::SecurityPolicy::maxMemoryRequest(256000000);
Magick::ResourceLimits::memory(1000000000);
}
};
using MagickCore::UpdatePixelTrait;
using MagickCore::BlendPixelTrait;
+ // Policy domains
+ using MagickCore::PolicyDomain;
+ using MagickCore::UndefinedPolicyDomain;
+ using MagickCore::CoderPolicyDomain;
+ using MagickCore::DelegatePolicyDomain;
+ using MagickCore::FilterPolicyDomain;
+ using MagickCore::PathPolicyDomain;
+ using MagickCore::ResourcePolicyDomain;
+ using MagickCore::SystemPolicyDomain;
+ using MagickCore::CachePolicyDomain;
+
// Preview types. Not currently used by Magick++
using MagickCore::PreviewType;
using MagickCore::UndefinedPreview;
--- /dev/null
+// This may look like C code, but it is really -*- C++ -*-
+//
+// Copyright Dirk Lemstra 2018
+//
+// Definition of the security policy.
+//
+
+#if !defined(Magick_SecurityPolicy_header)
+#define Magick_SecurityPolicy_header
+
+#include "Magick++/Include.h"
+#include <string>
+
+namespace Magick
+{
+ class MagickPPExport SecurityPolicy
+ {
+ public:
+
+ // The maximum number of significant digits to be printed.
+ static bool precision(const int precision_);
+
+ // Enables anonymous mapping for pixel cache.
+ static bool anonymousCacheMemoryMap();
+
+ // Enables anonymous virtual memory.
+ static bool anonymousSystemMemoryMap();
+
+ // The memory request limit in bytes.
+ static bool maxMemoryRequest(const MagickSizeType limit_);
+
+ // The number of passes to use when shredding files.
+ static bool shred(const int passes_);
+
+ private:
+ SecurityPolicy(void);
+
+ static bool setValue(const PolicyDomain domain_, const std::string name_,
+ const std::string value_);
+
+ }; // class SecurityPolicy
+
+} // Magick namespace
+
+#endif // Magick_SecurityPolicy_header
--- /dev/null
+// This may look like C code, but it is really -*- C++ -*-
+//
+// Copyright Dirk Lemstra 2018
+//
+// Implementation of the security policy.
+//
+
+#define MAGICKCORE_IMPLEMENTATION 1
+#define MAGICK_PLUSPLUS_IMPLEMENTATION 1
+
+#include "Magick++/SecurityPolicy.h"
+#include "Magick++/Exception.h"
+#include <string>
+
+using namespace std;
+
+bool Magick::SecurityPolicy::anonymousCacheMemoryMap()
+{
+ return(setValue(CachePolicyDomain,"memory-map","anonymous"));
+}
+
+bool Magick::SecurityPolicy::anonymousSystemMemoryMap()
+{
+ return(setValue(SystemPolicyDomain,"memory-map","anonymous"));
+}
+
+bool Magick::SecurityPolicy::precision(const int precision_)
+{
+ string
+ value;
+
+ value=to_string(precision_);
+ return(setValue(SystemPolicyDomain,"precision",value));
+}
+
+bool Magick::SecurityPolicy::maxMemoryRequest(const MagickSizeType limit_)
+{
+ string
+ value;
+
+ value=to_string(limit_);
+ return(setValue(SystemPolicyDomain,"max-memory-request",value));
+}
+
+bool Magick::SecurityPolicy::shred(const int passes_)
+{
+ string
+ value;
+
+ value=to_string(passes_);
+ return(setValue(SystemPolicyDomain,"shred",value));
+}
+
+Magick::SecurityPolicy::SecurityPolicy()
+{
+}
+
+bool Magick::SecurityPolicy::setValue(const PolicyDomain domain_,
+ const std::string name_,const std::string value_)
+{
+ MagickBooleanType
+ status;
+
+ GetPPException;
+ status=MagickCore::SetMagickSecurityPolicyValue(domain_,name_.c_str(),
+ value_.c_str(),exceptionInfo);
+ ThrowPPException(false);
+ return(status != MagickFalse);
+}
\ No newline at end of file