diff --git a/projects/libevent/Dockerfile b/projects/libevent/Dockerfile new file mode 100644 index 000000000..415ed3284 --- /dev/null +++ b/projects/libevent/Dockerfile @@ -0,0 +1,22 @@ +# Copyright 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +FROM gcr.io/oss-fuzz-base/base-builder +MAINTAINER a3at.mail@gmail.com +RUN apt-get update && apt-get install -y make autoconf automake libtool cmake +RUN git clone --depth 1 https://github.com/libevent/libevent.git libevent +WORKDIR libevent +COPY build.sh *.cc $SRC/ diff --git a/projects/libevent/build.sh b/projects/libevent/build.sh new file mode 100755 index 000000000..d6e44b6e8 --- /dev/null +++ b/projects/libevent/build.sh @@ -0,0 +1,32 @@ +#!/bin/bash -eu +# Copyright 2020 Google Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +################################################################################ + +# build project +sh autogen.sh +./configure --disable-openssl +make -j$(nproc) clean +make -j$(nproc) all +make install + +# build fuzzer +for fuzzers in $(find $SRC -name '*_fuzzer.cc'); do + fuzz_basename=$(basename -s .cc $fuzzers) + $CXX $CXXFLAGS -std=c++11 -Iinclude \ + $fuzzers $LIB_FUZZING_ENGINE ./.libs/libevent.a ./.libs/libevent_core.a \ + ./.libs/libevent_pthreads.a ./.libs/libevent_extra.a \ + -o $OUT/$fuzz_basename +done diff --git a/projects/libevent/parse_query_fuzzer.cc b/projects/libevent/parse_query_fuzzer.cc new file mode 100644 index 000000000..f3723ed7a --- /dev/null +++ b/projects/libevent/parse_query_fuzzer.cc @@ -0,0 +1,28 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include + +#include "libevent/include/event2/http.h" +#include "libevent/include/event2/keyvalq_struct.h" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + std::string fuzz_string(reinterpret_cast(data), size); + struct evkeyvalq headers; + evhttp_parse_query(fuzz_string.c_str(), &headers); + return 0; +} diff --git a/projects/libevent/project.yaml b/projects/libevent/project.yaml new file mode 100644 index 000000000..2b4282fc0 --- /dev/null +++ b/projects/libevent/project.yaml @@ -0,0 +1,10 @@ +homepage: "https://github.com/libevent/libevent" +language: c++ +primary_contact: "a3at.mail@gmail.com" +sanitizers: + - address + - memory + - undefined +architectures: + - x86_64 + - i386