• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2021 Google LLC
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16################################################################################
17
18# Debugging
19env
20
21# Some of the sanitizer flags cause issues with configure tests.
22# Pull them out of CFLAGS and pass them to configure instead.
23if [ $SANITIZER == "coverage" ]; then
24    CFLAGS="`echo \"$CFLAGS\" | sed \"s/ $COVERAGE_FLAGS//\"`"
25    sanitizer_opts="$COVERAGE_FLAGS"
26else
27    CFLAGS="`echo \"$CFLAGS\" | sed \"s/ $SANITIZER_FLAGS//\"`"
28    sanitizer_opts="$SANITIZER_FLAGS"
29fi
30# This is already added by --enable-fuzzer
31CFLAGS="`echo \"$CFLAGS\" | sed 's/ -fsanitize=fuzzer-no-link//'`"
32
33# Copy optimization flag to LDFLAGS for UBSan object-size check.
34OPTFLAG="`echo \"$CFLAGS\" | sed 's/^.*\(-O[^ ]\).*$/\1/'`"
35export LDFLAGS="${LDFLAGS:-}${LDFLAGS:+ }$OPTFLAG"
36
37# Build sudo with static libs and enable fuzzing targets.
38# All fuzz targets are integrated into the build process.
39./configure --disable-shared --disable-shared-libutil --enable-static-sudoers \
40    --enable-sanitizer="$sanitizer_opts" --enable-fuzzer \
41    --enable-fuzzer-engine="$LIB_FUZZING_ENGINE" --enable-fuzzer-linker="$CXX" \
42    --enable-warnings --enable-werror
43make -j$(nproc) && make FUZZ_DESTDIR=$OUT install-fuzzer
44