summaryrefslogtreecommitdiff
path: root/libsparse/sparse_fuzzer.cpp
blob: 42f331fc3bbc776c8584e52168b7ccff33256645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "include/sparse/sparse.h"

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
  if (size < 2 * sizeof(wchar_t)) return 0;

  int64_t blocksize = 4096;
  struct sparse_file* file = sparse_file_new(size, blocksize);
  if (!file) {
    return 0;
  }

  unsigned int block = 1;
  sparse_file_add_data(file, &data, size, block);
  sparse_file_destroy(file);
  return 0;
}