diff --git a/targets/pcre2/Dockerfile b/targets/pcre2/Dockerfile index 180d2e3dd..223b65aa4 100644 --- a/targets/pcre2/Dockerfile +++ b/targets/pcre2/Dockerfile @@ -19,4 +19,4 @@ MAINTAINER kcc@google.com RUN apt-get install -y make autoconf automake libtool subversion RUN svn co svn://vcs.exim.org/pcre2/code/trunk pcre2 -COPY build.sh pcre2_fuzzer.cc /src/ +COPY build.sh /src/ diff --git a/targets/pcre2/build.sh b/targets/pcre2/build.sh index 4b7783a21..cae6020f2 100755 --- a/targets/pcre2/build.sh +++ b/targets/pcre2/build.sh @@ -19,11 +19,10 @@ cd pcre2 # build the library. ./autogen.sh -./configure --enable-never-backslash-C --with-match-limit=1000 --with-match-limit-recursion=1000 +./configure --enable-fuzz-support --enable-never-backslash-C --with-match-limit=1000 --with-match-limit-recursion=1000 make clean all # Build the target. -$CXX $CXXFLAGS -std=c++11 -I src \ - /src/pcre2_fuzzer.cc -o /out/pcre2_fuzzer \ - -Wl,--whole-archive .libs/*.a -Wl,-no-whole-archive $FUZZER_LDFLAGS \ - -lfuzzer +$CXX $CXXFLAGS -o /out/pcre2_fuzzer \ + -lfuzzer .libs/libpcre2-fuzzsupport.a .libs/libpcre2-8.a \ + $FUZZER_LDFLAGS diff --git a/targets/pcre2/pcre2_fuzzer.cc b/targets/pcre2/pcre2_fuzzer.cc deleted file mode 100644 index f6fb828a3..000000000 --- a/targets/pcre2/pcre2_fuzzer.cc +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2016 Google Inc. All Rights Reserved. -// Licensed under the Apache License, Version 2.0 (the "License"); - -#include -#include "pcre2posix.h" - -using std::string; - -extern "C" int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size) { - if (size < 1) return 0; - regex_t preg; - string str(reinterpret_cast(data), size); - string pat(str); - int flags = data[size/2] - 'a'; // Make it 0 when the byte is 'a'. - if (0 == regcomp(&preg, pat.c_str(), flags)) { - regmatch_t pmatch[5]; - regexec(&preg, str.c_str(), 5, pmatch, 0); - regfree(&preg); - } - return 0; -}