From cdbbca0fb06b9179334f21f355d9103df85ab2eb Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Fri, 25 Nov 2022 17:07:52 +0000 Subject: [PATCH] build: Link libgit2 via LIB_FUZZING_ENGINE Signed-off-by: Paulo Gomes --- tests/fuzz/oss_fuzz_postbuild.sh | 6 +++++- tests/fuzz/oss_fuzz_prebuild.sh | 13 ++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/fuzz/oss_fuzz_postbuild.sh b/tests/fuzz/oss_fuzz_postbuild.sh index 36818fed..2b155772 100755 --- a/tests/fuzz/oss_fuzz_postbuild.sh +++ b/tests/fuzz/oss_fuzz_postbuild.sh @@ -20,10 +20,14 @@ set -euxo pipefail # Use it for unsetting any environment variables that may impact other building # processes. +if [[ -n "${PRE_LIB_FUZZING_ENGINE}" ]]; then + export LIB_FUZZING_ENGINE="${PRE_LIB_FUZZING_ENGINE}" +fi + unset TARGET_DIR unset CGO_ENABLED unset LIBRARY_PATH unset PKG_CONFIG_PATH unset CGO_CFLAGS unset CGO_LDFLAGS -unset ADDITIONAL_LIBS +unset PRE_LIB_FUZZING_ENGINE diff --git a/tests/fuzz/oss_fuzz_prebuild.sh b/tests/fuzz/oss_fuzz_prebuild.sh index c4d66c65..de1e4ed3 100755 --- a/tests/fuzz/oss_fuzz_prebuild.sh +++ b/tests/fuzz/oss_fuzz_prebuild.sh @@ -70,4 +70,15 @@ else curl -s --fail https://raw.githubusercontent.com/fluxcd/image-reflector-controller/${REFLECTOR_VER}/config/crd/bases/image.toolkit.fluxcd.io_imagepolicies.yaml -o controllers/testdata/crd/imagepolicies.yaml fi -export ADDITIONAL_LIBS="${TARGET_DIR}/lib/libgit2.a" +# Temporary hack whilst libgit2 is still in use. +# Enables the fuzzing compilation to link libgit2. +# +# After building the fuzzers, the value of +# LIB_FUZZING_ENGINE is reset to what it was before +# it to avoid side effects onto other repositories. +# +# For context refer to: +# https://github.com/google/oss-fuzz/pull/9063 +export PRE_LIB_FUZZING_ENGINE="${LIB_FUZZING_ENGINE}" + +export LIB_FUZZING_ENGINE="${LIB_FUZZING_ENGINE} -Wl,--start-group ${TARGET_DIR}/lib/libgit2.a"