libvips/fuzz/test_fuzz.sh
Kleis Auke Wolthuizen 5ab66e16e1
Fix UBSan errors (#1948)
* Ensure UBSan exits with a non-zero code on error

* Avoid misaligned member access in mosaic_fuzzer

* Add missing VIPS_CLIP in scRGB2sRGB/scRGB2BW

* Fix UBSan error in flatten

By using saturated casts for the int types (copied from vips_cast).

* CI: ensure fuzzer log is printed on error

* Avoid UB in heifload

* Revert flatten change

I could no longer reproduce this with clang 12 locally.

* Indentation fixes [skip ci]
2021-09-12 13:14:24 +01:00

30 lines
622 B
Bash
Executable File

#!/bin/sh
#set -x
set -e
. ../test/variables.sh
# Glib is built without -fno-omit-frame-pointer. We need
# to disable the fast unwinder to get full stacktraces.
export ASAN_OPTIONS="$ASAN_OPTIONS:fast_unwind_on_malloc=0:allocator_may_return_null=1"
export UBSAN_OPTIONS="$UBSAN_OPTIONS:print_stacktrace=1"
# Hide all warning messages from vips.
export VIPS_WARNING=0
ret=0
for fuzzer in *_fuzzer; do
for file in $top_srcdir/fuzz/common_fuzzer_corpus/*; do
exit_code=0
./$fuzzer $file || exit_code=$?
if [ $exit_code -ne 0 ]; then
echo FAIL $fuzzer $file
ret=1
fi
done
done
exit $ret