From a0688e8e7b58c156f5809c272b5884bfe75f68ae Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 20 Dec 2016 20:52:50 -0600 Subject: [PATCH] Ouch, finish previous change --- test/fuzzing/Makefile.am | 3 ++- test/fuzzing/hb-fuzzer.cc | 30 ++++-------------------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/test/fuzzing/Makefile.am b/test/fuzzing/Makefile.am index 7b0eb9452..3ea8605bd 100644 --- a/test/fuzzing/Makefile.am +++ b/test/fuzzing/Makefile.am @@ -30,14 +30,15 @@ LDADD = \ $(NULL) hb_fuzzer_SOURCES = \ + hb-fuzzer.hh \ hb-fuzzer.cc \ + main.cc \ $(NULL) hb_fuzzer_LDADD = \ $(LDADD) \ $(NULL) hb_fuzzer_CPPFLAGS = \ $(AM_CPPFLAGS) \ - -DMAIN \ $(NULL) hb_fuzzer_DEPENDENCIES = \ lib \ diff --git a/test/fuzzing/hb-fuzzer.cc b/test/fuzzing/hb-fuzzer.cc index c9f15d831..79f322297 100644 --- a/test/fuzzing/hb-fuzzer.cc +++ b/test/fuzzing/hb-fuzzer.cc @@ -1,10 +1,10 @@ -#include -#include +#include "hb-fuzzer.hh" + #include #include -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ hb_blob_t *blob = hb_blob_create((const char *)data, size, HB_MEMORY_MODE_READONLY, NULL, NULL); hb_face_t *face = hb_face_create(blob, 0); @@ -50,25 +50,3 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { hb_blob_destroy(blob); return 0; } - -#ifdef MAIN -#include -#include -#include -#include - -std::string FileToString(const std::string &Path) { - /* TODO This silently passes if file does not exist. Fix it! */ - std::ifstream T(Path.c_str()); - return std::string((std::istreambuf_iterator(T)), - std::istreambuf_iterator()); -} - -int main(int argc, char **argv) { - for (int i = 1; i < argc; i++) { - std::string s = FileToString(argv[i]); - std::cout << argv[i] << std::endl; - LLVMFuzzerTestOneInput((const unsigned char*)s.data(), s.size()); - } -} -#endif