Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 49943e8e authored by Hamzeh Zawawy's avatar Hamzeh Zawawy Committed by android-build-merger
Browse files

Merge "Add fuzzer for libsparse"

am: c7ea8817

Change-Id: I080f650680d4c3a5279fe70e86c2f12a71eefbba
parents 06a8db71 c7ea8817
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -82,3 +82,15 @@ python_binary_host {
        },
    },
}

cc_fuzz {
    name: "sparse_fuzzer",
    host_supported: false,
    srcs: [
        "sparse_fuzzer.cpp",
    ],
    static_libs: [
        "libsparse",
        "liblog",
    ],
}
+16 −0
Original line number Diff line number Diff line
#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;
}