From 2a3b5a425eb0a510865fd780562ec41dc4a782a0 Mon Sep 17 00:00:00 2001 From: DavidKorczynski Date: Fri, 2 Apr 2021 14:47:07 +0100 Subject: [PATCH] boost: fix build. (#5565) * boost: fix build. * Add header to fuzzer. --- projects/boost/boost_regex_fuzzer.cc | 19 +++++++++++++++---- projects/boost/build.sh | 4 +++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/projects/boost/boost_regex_fuzzer.cc b/projects/boost/boost_regex_fuzzer.cc index 018a04b4b..dbc5ea831 100644 --- a/projects/boost/boost_regex_fuzzer.cc +++ b/projects/boost/boost_regex_fuzzer.cc @@ -1,3 +1,14 @@ +/* Copyright 2021 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. +*/ // 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 boost repository. @@ -25,16 +36,16 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) { size_t regex_length = fuzzed_data.ConsumeIntegral(); // Second value is regexp string whose length is `regex_length` std::string regex_string = fuzzed_data.ConsumeBytesAsString(regex_length); - boost::regex e(regex_string); - // Last value is the text to be matched - std::string text = fuzzed_data.ConsumeRemainingBytesAsString(); + try { + boost::regex e(regex_string); + // Last value is the text to be matched + std::string text = fuzzed_data.ConsumeRemainingBytesAsString(); #ifdef DEBUG std::cout << "Regexp string: " << regex_string << "Size: " << regex_string.size() << std::endl; std::cout << "Text: " << text << "Size: " << text.size() << std::endl; #endif - try { boost::match_results what; bool match = boost::regex_match(text, what, e, boost::match_default | boost::match_partial); diff --git a/projects/boost/build.sh b/projects/boost/build.sh index b34d55f35..37552ed3b 100755 --- a/projects/boost/build.sh +++ b/projects/boost/build.sh @@ -16,7 +16,9 @@ ################################################################################ # Build boost -./bootstrap.sh && ./b2 headers +CXXFLAGS="$CXXFLAGS -stdlib=libc++ -pthread" LDFLAGS="-stdlib=libc++" \ + ./bootstrap.sh --with-toolset=clang --prefix=/usr; +./b2 toolset=clang cxxflags="$CXXFLAGS -stdlib=libc++ -pthread" linkflags="-stdlib=libc++ -pthread" headers; # Very simple build rule, but sufficient here. #boost regexp