1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

lib:fuzzing: Reformat shell scripts

shfmt -f lib/fuzzing/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Andreas Schneider 2022-02-19 16:08:16 +01:00 committed by Andreas Schneider
parent 8246ccc23d
commit 1e88064170
3 changed files with 62 additions and 64 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh -e
DIST=ubuntu2004
SCRIPT_DIR=`dirname $0`
SCRIPT_DIR=$(dirname $0)
$SCRIPT_DIR/../../../bootstrap/generated-dists/$DIST/bootstrap.sh
$SCRIPT_DIR/../../../bootstrap/generated-dists/$DIST/locale.sh

View File

@ -16,34 +16,33 @@ OUT=$1
seeds_found=no
for bin in $OUT/fuzz_*
do
# we only want to look at the elf files, not the zips
if [ ${bin%_seed_corpus.zip} != $bin ]; then
continue
fi
# Confirm that the chrpath was reset to lib/ in the same directory
# as the binary. RPATH (not RUNPATH) is critical, otherwise
# libraries used by libraries won't be found on the oss-fuzz
# target host.
chrpath -l $bin | grep 'RPATH=$ORIGIN/lib'
for bin in $OUT/fuzz_*; do
# we only want to look at the elf files, not the zips
if [ ${bin%_seed_corpus.zip} != $bin ]; then
continue
fi
# Confirm that the chrpath was reset to lib/ in the same directory
# as the binary. RPATH (not RUNPATH) is critical, otherwise
# libraries used by libraries won't be found on the oss-fuzz
# target host.
chrpath -l $bin | grep 'RPATH=$ORIGIN/lib'
# Confirm that we link to at least some libraries in this
# directory (shows that the libraries were found and copied).
ldd $bin | grep "$OUT/lib"
num_libs=$(ldd $bin | grep -v ld-linux | grep -v linux-vdso | grep -v "$OUT/lib"| wc -l)
# Confirm that we link to at least some libraries in this
# directory (shows that the libraries were found and copied).
ldd $bin | grep "$OUT/lib"
num_libs=$(ldd $bin | grep -v ld-linux | grep -v linux-vdso | grep -v "$OUT/lib" | wc -l)
if [ 0$num_libs -ne 0 ]; then
echo "some libraries not linked to $ORIGIN/lib, oss-fuzz will fail!"
exit 1
fi
if [ 0$num_libs -ne 0 ]; then
echo "some libraries not linked to $ORIGIN/lib, oss-fuzz will fail!"
exit 1
fi
if [ -f ${bin}_seed_corpus.zip ]; then
seeds_found=yes
fi
if [ -f ${bin}_seed_corpus.zip ]; then
seeds_found=yes
fi
done
if [ $seeds_found = no ]; then
echo "no seed zip files were found!"
exit 1
echo "no seed zip files were found!"
exit 1
fi

View File

@ -56,13 +56,13 @@ export PYTHON
# correctly
case "$SANITIZER" in
address)
address)
SANITIZER_ARG='--address-sanitizer'
;;
undefined)
undefined)
SANITIZER_ARG='--undefined-sanitizer'
;;
coverage)
coverage)
# Thankfully clang operating as ld has no objection to the
# cc style options, so we can just set ADDITIONAL_LDFLAGS
# to ensure the coverage build is done, despite waf splitting
@ -71,7 +71,7 @@ case "$SANITIZER" in
export ADDITIONAL_LDFLAGS
SANITIZER_ARG=''
;;
;;
esac
# $LIB_FUZZING_ENGINE is provided by the oss-fuzz "compile" command
@ -81,14 +81,14 @@ esac
# header instead of RUNPATH header. Modern linkers use RUNPATH by
# default.
./configure -C --without-gettext --enable-debug --enable-developer \
--enable-libfuzzer \
$SANITIZER_ARG \
--disable-warnings-as-errors \
--abi-check-disable \
"--fuzz-target-ldflags=-Wl,--disable-new-dtags $LIB_FUZZING_ENGINE" \
--nonshared-binary=ALL \
"$@" \
LINK_CC="$CXX"
--enable-libfuzzer \
$SANITIZER_ARG \
--disable-warnings-as-errors \
--abi-check-disable \
"--fuzz-target-ldflags=-Wl,--disable-new-dtags $LIB_FUZZING_ENGINE" \
--nonshared-binary=ALL \
"$@" \
LINK_CC="$CXX"
make -j
@ -236,37 +236,36 @@ mkdir -p $OUT/lib
# See how the runtime linker seems to honour the RPATH for
# dependencies of dependencies in this case. This helps us us lot.
for x in bin/fuzz_*
do
# Copy any system libraries needed by this fuzzer to $OUT/lib.
for x in bin/fuzz_*; do
# Copy any system libraries needed by this fuzzer to $OUT/lib.
# We run ldd on $x, the fuzz_binary in bin/ which has not yet had
# the RPATH altered. This is clearer for debugging in local
# development builds as $OUT is not cleaned between runs.
#
# Otherwise trying to re-run this can see cp can fail with:
# cp: '/out/lib/libgcc_s.so.1' and '/out/lib/libgcc_s.so.1' are the same file
# which is really confusing!
# We run ldd on $x, the fuzz_binary in bin/ which has not yet had
# the RPATH altered. This is clearer for debugging in local
# development builds as $OUT is not cleaned between runs.
#
# Otherwise trying to re-run this can see cp can fail with:
# cp: '/out/lib/libgcc_s.so.1' and '/out/lib/libgcc_s.so.1' are the same file
# which is really confusing!
# The cut for ( and ' ' removes the special case references to:
# linux-vdso.so.1 => (0x00007ffe8f2b2000)
# /lib64/ld-linux-x86-64.so.2 (0x00007fc63ea6f000)
# The cut for ( and ' ' removes the special case references to:
# linux-vdso.so.1 => (0x00007ffe8f2b2000)
# /lib64/ld-linux-x86-64.so.2 (0x00007fc63ea6f000)
ldd $x | cut -f 2 -d '>' | cut -f 1 -d \( | cut -f 2 -d ' ' | xargs -i cp \{\} $OUT/lib/
ldd $x | cut -f 2 -d '>' | cut -f 1 -d \( | cut -f 2 -d ' ' | xargs -i cp \{\} $OUT/lib/
cp $x $OUT/
bin=`basename $x`
cp $x $OUT/
bin=$(basename $x)
# This means the copied libraries are found on the runner.
#
# The binaries should we built with RPATH, not RUNPATH, to allow
# libraries used by libraries to be found. This command retains the
# RPATH/RUNPATH header and only changes the path. We later verify this
# in the check_build.sh script.
chrpath -r '$ORIGIN/lib' $OUT/$bin
# This means the copied libraries are found on the runner.
#
# The binaries should we built with RPATH, not RUNPATH, to allow
# libraries used by libraries to be found. This command retains the
# RPATH/RUNPATH header and only changes the path. We later verify this
# in the check_build.sh script.
chrpath -r '$ORIGIN/lib' $OUT/$bin
# Truncate the original binary to save space
echo -n > $x
# Truncate the original binary to save space
echo -n >$x
done
@ -288,8 +287,8 @@ chrpath -d $OUT/lib/*
# beside their executables.
wget https://gitlab.com/samba-team/samba-fuzz-seeds/-/jobs/artifacts/master/download?job=zips \
-O seeds.zip
-O seeds.zip
# We might not have unzip, but we do have python
$PYTHON -mzipfile -e seeds.zip $OUT
$PYTHON -mzipfile -e seeds.zip $OUT
rm -f seeds.zip