#include "utils.cc"
#include "encoder_utils.cc"
+static bool validateFileName(const std::string &fileName)
+{
+ // Signature: this will most likely cause a timeout.
+ if (fileName.find("%#") != -1)
+ return false;
+
+ return true;
+}
+
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
- return fuzzEncoderWithStringFilename("label", Data, Size);
+ return fuzzEncoderWithStringFilename("label", Data, Size, validateFileName);
}
#include "travis.cc"
-static int fuzzEncoderWithStringFilename(const std::string encoder, const uint8_t *Data, size_t Size)
+static int fuzzEncoderWithStringFilename(const std::string encoder, const uint8_t *Data, size_t Size, bool (*validate)(const std::string &) = NULL)
{
// Allow a bit extra to make sure we do proper bounds checking in Magick++
if (Size > MagickPathExtent)
std::string fileName(reinterpret_cast<const char*>(Data), Size);
+ // Can be used to deny specific file names
+ if ((validate != NULL) && (validate(fileName) == false))
+ return 0;
+
Magick::Image image;
try {
image.read(encoder + ":" + fileName);