aboutsummaryrefslogtreecommitdiffstats
path: root/fuzz/qpdf_read_memory_fuzzer.cc
blob: d4db62b072af90fe3ea475d6b19a0628a800de0b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "qpdf/qpdf-c.h"

#include <algorithm>
#include <cstddef>
#include <cstdlib>

extern "C" int LLVMFuzzerTestOneInput(const unsigned char* data, size_t size) {
  const size_t kMaxSize = 64 * 1024; // 64 KiB
  size = std::min(size, kMaxSize);
  _qpdf_data* qpdf = qpdf_init();
  const char* buffer = reinterpret_cast<const char*>(data);
  qpdf_read_memory(qpdf, /*description=*/"", buffer, size, /*password=*/"");
  qpdf_cleanup(&qpdf);
  return 0;
}