From e445a90d9445440d6672c8b0ab3f148bf63bc675 Mon Sep 17 00:00:00 2001 From: tsdgeos Date: Tue, 9 Apr 2019 20:23:05 +0200 Subject: [PATCH] Add libical (#2298) --- projects/libical/Dockerfile | 26 ++++++++++++++++++ projects/libical/build.sh | 6 ++++ projects/libical/libical_fuzzer.cc | 44 ++++++++++++++++++++++++++++++ projects/libical/project.yaml | 8 ++++++ 4 files changed, 84 insertions(+) create mode 100644 projects/libical/Dockerfile create mode 100644 projects/libical/build.sh create mode 100644 projects/libical/libical_fuzzer.cc create mode 100644 projects/libical/project.yaml diff --git a/projects/libical/Dockerfile b/projects/libical/Dockerfile new file mode 100644 index 000000000..a95e778a9 --- /dev/null +++ b/projects/libical/Dockerfile @@ -0,0 +1,26 @@ +# Copyright 2019 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 tsdgeos@gmail.com +RUN apt-get install --yes cmake +RUN git clone --depth 1 https://github.com/libical/libical.git +COPY build.sh $SRC +COPY libical_fuzzer.cc $SRC +WORKDIR libical + + + diff --git a/projects/libical/build.sh b/projects/libical/build.sh new file mode 100644 index 000000000..eb0587f92 --- /dev/null +++ b/projects/libical/build.sh @@ -0,0 +1,6 @@ +cmake . -DBUILD_SHARED_LIBS=OFF -DICAL_GLIB=False +make install -j$(nproc) + +$CXX $CXXFLAGS -std=c++11 $SRC/libical_fuzzer.cc -lFuzzingEngine /usr/local/lib/libical.a -o $OUT/libical_fuzzer + +find . -name *.ics -print | zip -q $OUT/libical_fuzzer_seed_corpus.zip -@ diff --git a/projects/libical/libical_fuzzer.cc b/projects/libical/libical_fuzzer.cc new file mode 100644 index 000000000..23f1b7665 --- /dev/null +++ b/projects/libical/libical_fuzzer.cc @@ -0,0 +1,44 @@ +/* +# Copyright 2019 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. +# +################################################################################ +*/ + +/* + Usage: + python infra/helper.py build_image libical + python infra/helper.py build_fuzzers --sanitizer undefined|address|memory libical + python infra/helper.py run_fuzzer libical libical_fuzzer +*/ + +#include +#include +#include + +#include + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + char *ical_string = (char*)malloc(size + 1); + memcpy(ical_string, data, size); + ical_string[size] = '\0'; + + icalcomponent *component = icalparser_parse_string(ical_string); + icalcomponent_free(component); + + free(ical_string); + + return 0; +} diff --git a/projects/libical/project.yaml b/projects/libical/project.yaml new file mode 100644 index 000000000..0e050099e --- /dev/null +++ b/projects/libical/project.yaml @@ -0,0 +1,8 @@ +homepage: https://github.com/libical/libical +primary_contact: tsdgeos@gmail.com +auto_ccs: + - allen.d.winter@gmail.com +sanitizers: + - address + - memory + - undefined