From 924b41d903a20ed3feb656692de81c8c6736e0ee Mon Sep 17 00:00:00 2001 From: Mike Aizatsky Date: Tue, 6 Dec 2016 12:12:33 -0800 Subject: [PATCH] [harfbuzz] using fuzzer from harfbuzz repo --- projects/harfbuzz/Dockerfile | 2 +- projects/harfbuzz/build.sh | 9 ++++-- projects/harfbuzz/harfbuzz_fuzzer.cc | 46 ---------------------------- 3 files changed, 7 insertions(+), 50 deletions(-) delete mode 100644 projects/harfbuzz/harfbuzz_fuzzer.cc diff --git a/projects/harfbuzz/Dockerfile b/projects/harfbuzz/Dockerfile index 6065f2c1b..5fd5c6450 100644 --- a/projects/harfbuzz/Dockerfile +++ b/projects/harfbuzz/Dockerfile @@ -20,4 +20,4 @@ RUN apt-get install -y make autoconf automake libtool ragel pkg-config RUN git clone --depth 1 https://anongit.freedesktop.org/git/harfbuzz.git WORKDIR harfbuzz -COPY build.sh harfbuzz_fuzzer.cc $SRC/ +COPY build.sh $SRC/ diff --git a/projects/harfbuzz/build.sh b/projects/harfbuzz/build.sh index 463234a08..e1480693c 100755 --- a/projects/harfbuzz/build.sh +++ b/projects/harfbuzz/build.sh @@ -18,8 +18,11 @@ # Build the library. ./autogen.sh ./configure -make -j$(nproc) clean all +make clean +make -j$(nproc) V=1 alL +make -C src V=1 fuzzing $CXX $CXXFLAGS -std=c++11 -Isrc \ - $SRC/harfbuzz_fuzzer.cc -o $OUT/harfbuzz_fuzzer \ - -lfuzzer src/.libs/*.o src/hb-ucdn/.libs/*.o + ./test/fuzzing/hb-fuzzer.cc -o $OUT/hb-fuzzer \ + -lfuzzer ./src/.libs/libharfbuzz-fuzzing.a + diff --git a/projects/harfbuzz/harfbuzz_fuzzer.cc b/projects/harfbuzz/harfbuzz_fuzzer.cc deleted file mode 100644 index 771c9b2cc..000000000 --- a/projects/harfbuzz/harfbuzz_fuzzer.cc +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include -#include -#include - -#include -#include - -// Entry point for LibFuzzer. -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { - const char* dataPtr = reinterpret_cast(data); - hb_blob_t* blob = hb_blob_create(dataPtr, size, HB_MEMORY_MODE_READONLY, NULL, - NULL); - hb_face_t* face = hb_face_create(blob, 0); - hb_font_t* font = hb_font_create(face); - hb_ot_font_set_funcs(font); - hb_font_set_scale(font, 12, 12); - - { - const char text[] = "ABCDEXYZ123@_%&)*$!"; - hb_buffer_t* buffer = hb_buffer_create(); - hb_buffer_add_utf8(buffer, text, -1, 0, -1); - hb_buffer_guess_segment_properties(buffer); - hb_shape(font, buffer, NULL, 0); - hb_buffer_destroy(buffer); - } - - uint32_t text32[16] = { 0 }; - if (size > sizeof(text32)) { - memcpy(text32, data + size - sizeof(text32), sizeof(text32)); - hb_buffer_t* buffer = hb_buffer_create(); - size_t text32len = sizeof(text32) / sizeof(text32[0]); - hb_buffer_add_utf32(buffer, text32, text32len, 0, -1); - hb_buffer_guess_segment_properties(buffer); - hb_shape(font, buffer, NULL, 0); - hb_buffer_destroy(buffer); - } - - hb_font_destroy(font); - hb_face_destroy(face); - hb_blob_destroy(blob); - return 0; -}