]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
oss-fuzz: turn on the alignment check explicitly
authorEvgeny Vereshchagin <evvers@ya.ru>
Fri, 18 Nov 2022 07:09:30 +0000 (07:09 +0000)
committerEvgeny Vereshchagin <evvers@ya.ru>
Fri, 18 Nov 2022 07:14:15 +0000 (07:14 +0000)
to somewhat cover architectures where unaligned access can lead to
crashes and make it possible for OSS-Fuzz to catch issues like
https://github.com/util-linux/util-linux/pull/1906.

With this patch applied the libblkid fuzz target built with the OSS-Fuzz
toolchain triggers "runtime error: load of misaligned address" in `probe_exfat`
so it seems to be working.

tools/oss-fuzz.sh

index 3bb9d78fe158c6484e8d697fceb038ec211a4ada..4aa7f23b09a898b86c6d3380bb0da4a3a9ca6535 100755 (executable)
@@ -17,6 +17,13 @@ export CXXFLAGS=${CXXFLAGS:-$flags}
 export OUT=${OUT:-$(pwd)/out}
 mkdir -p $OUT
 
+if [[ "$SANITIZER" == undefined ]]; then
+    additional_ubsan_checks=alignment
+    UBSAN_FLAGS="-fsanitize=$additional_ubsan_checks -fno-sanitize-recover=$additional_ubsan_checks"
+    CFLAGS+=" $UBSAN_FLAGS"
+    CXXFLAGS+=" $UBSAN_FLAGS"
+fi
+
 ./autogen.sh
 ./configure --disable-all-programs --enable-libuuid --enable-libfdisk --enable-last --enable-fuzzing-engine --enable-libmount --enable-libblkid
 make -j$(nproc) V=1 check-programs