Skip to content

Add reallocarray fallback for macOS portability #490

Add reallocarray fallback for macOS portability

Add reallocarray fallback for macOS portability #490

name: Build and Fuzz
on:
push:
branches: ["*"]
pull_request:
jobs:
build-and-fuzz:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
run: |
set -euo pipefail
sudo apt-get update
sudo apt-get install -y \
autoconf automake libtool pkg-config \
libev-dev libpcre2-dev libc-ares-dev \
libssl-dev libseccomp-dev clang
for version in 19 18 17 16 15 14; do
if sudo apt-get install -y \
"clang-${version}" \
"libclang-rt-${version}-dev" \
"libfuzzer-${version}-dev"; then
echo "Using clang-${version} for fuzzing"
echo "FUZZ_CC=clang-${version}" >> "$GITHUB_ENV"
FOUND=1
break
else
echo "clang-${version} toolchain unavailable, trying next version"
fi
done
if [[ ${FOUND:-0} -eq 0 ]]; then
echo "error: unable to install clang with libFuzzer support" >&2
exit 1
fi
- name: Generate build system
run: |
AUTOCONF_VERSION=2.71 AUTOMAKE_VERSION=1.16 ./autogen.sh
- name: Configure
run: ./configure --disable-dependency-tracking
- name: Build
run: make -j$(nproc)
- name: Run tests
env:
SKIP_BAD_REQUEST_TEST: 1
run: make check
- name: Run fuzzers
env:
FUZZ_OPTIONAL: 0
FUZZ_RUNTIME: 120
FUZZ_VERBOSE: 0
FUZZ_PARALLEL: 1
run: |
set -euo pipefail
if ! tests/fuzz/run_fuzz.sh >fuzz.log 2>&1; then
cat fuzz.log >&2
exit 1
fi
- name: Upload crash artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: fuzzer-crashes
path: |
tests/fuzz/crash-*
tests/fuzz/leak-*
tests/fuzz/timeout-*
tests/fuzz/bin/*.log
if-no-files-found: ignore
- name: Upload corpus
if: always()
uses: actions/upload-artifact@v7
with:
name: fuzzer-corpus
path: tests/fuzz/corpus/
if-no-files-found: ignore
build-macos:
runs-on: macos-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Install dependencies
run: |
brew install libev pcre2 c-ares openssl autoconf automake libtool gettext
brew link --force gettext
- name: Generate build system
run: ./autogen.sh
- name: Configure
run: |
BREW_CFLAGS=""
BREW_LDFLAGS=""
BREW_PKG=""
for dep in libev pcre2 c-ares openssl; do
prefix="$(brew --prefix "$dep")"
BREW_CFLAGS="${BREW_CFLAGS} -I${prefix}/include"
BREW_LDFLAGS="${BREW_LDFLAGS} -L${prefix}/lib"
BREW_PKG="${BREW_PKG:+${BREW_PKG}:}${prefix}/lib/pkgconfig"
done
./configure --disable-dependency-tracking \
CC=cc \
CPPFLAGS="${BREW_CFLAGS}" \
LDFLAGS="${BREW_LDFLAGS}" \
PKG_CONFIG_PATH="${BREW_PKG}"
- name: Build
run: make -j$(sysctl -n hw.ncpu)
- name: Run tests
env:
SKIP_BAD_REQUEST_TEST: 1
run: make check