Skip to content

Commit

Permalink
add boost/regex fuzzer (google#851)
Browse files Browse the repository at this point in the history
  • Loading branch information
kcc authored and oliverchang committed Sep 21, 2017
1 parent d36b284 commit 8bcc8e1
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
26 changes: 26 additions & 0 deletions projects/boost/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2017 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
RUN apt-get update && apt-get install -y g++

RUN git clone --recursive https://github.com/boostorg/boost.git
WORKDIR boost
# This bootstrap boost with the g++ toolchain.
# The actual build will need to use CXX/CXXFLAGS provided by OSS-Fuzz.
RUN ./bootstrap.sh && ./b2 headers
# Preferably, move boost_regex_fuzzer.cc to the boost repository.
COPY build.sh boost_regex_fuzzer.cc $SRC/
16 changes: 16 additions & 0 deletions projects/boost/boost_regex_fuzzer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// From https://svn.boost.org/trac10/ticket/12818
// This fuzz target can likely be enhanced to exercise more code.
// The ideal place for this fuzz target is the bost repository.
#include <boost/regex.hpp>
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
try {
std::string str((char *)Data, Size);
boost::regex e(str);
boost::match_results<std::string::const_iterator> what;
boost::regex_match(str, what, e,
boost::match_default | boost::match_partial);

} catch (const std::exception &) {
}
return 0;
}
26 changes: 26 additions & 0 deletions projects/boost/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash -eu
# Copyright 2017 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.
#
################################################################################


# Very simple build rule, but sufficient here.
$CXX $CXXFLAGS -I . ../boost_regex_fuzzer.cc libs/regex/src/*.cpp $LIB_FUZZING_ENGINE -o boost_regex_fuzzer

# Copy the fuzzer executables, zip-ed corpora, option and dictionary files to $OUT
find . -name '*_fuzzer' -exec cp -v '{}' $OUT ';'
# find . -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';' # If you have dictionaries.
# find . -name '*_fuzzer.options' -exec cp -v '{}' $OUT ';' # If you have custom options.
# find . -name '*_fuzzer_seed_corpus.zip' -exec cp -v '{}' $OUT ';' # If you have seed corpora (you better have them!)
9 changes: 9 additions & 0 deletions projects/boost/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
homepage: "http://www.boost.org/"

# TODO: add actual boost maintainers here.
# Provide the e-mail for the primary contact and others:
# Un-comment the below lines to make auto-cc work.
# primary_contact: "[email protected]"
# auto_ccs:
# - "[email protected]"
# - "[email protected]"

0 comments on commit 8bcc8e1

Please sign in to comment.