Skip to content

Commit afdf1ca

Browse files
authored
flac: only disable signed integer sanitizing on decoder fuzzers (#7687)
oss-fuzz has reported numerous signed integer overflow problems in flac that cannot be reasonably fixed. The problem is that flac uses some math that is numerically unstable when fed with random data, and as these are only audio samples, this overflow is not a problem. Therefore, I added `__attribute__((no_sanitize("signed-integer-overflow")))` to a few functions in the flac sources. However, while a decoder fed with random data has this problem, an decoder that is being used to verify an encoder fed with random data should never overflow. As the same functions are used, the flac sources should be compiled twice: once with the mentioned attributes for the decoder fuzzers, and once without them for the encoder fuzzers. Note that the define passed in this code is not yet integrated in libflac, but this change should happen first or else the old bugs appear again
1 parent c041353 commit afdf1ca

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

projects/flac/build.sh

+15-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,23 @@ else
4848
fi
4949
make -j$(nproc)
5050

51-
# Build fuzzer_exo, copy other fuzzers
51+
# Copy encoder fuzzers
5252
cd $SRC/flac/oss-fuzz
53-
cp fuzzer_encoder fuzzer_encoder_v2 fuzzer_decoder $OUT
53+
cp fuzzer_encoder fuzzer_encoder_v2 $OUT
54+
55+
# Build libflac again for decoder fuzzers, but now with addition CFLAG
56+
export CFLAGS="$CFLAGS -DFUZZING_BUILD_MODE_NO_SANITIZE_SIGNED_INTEGER_OVERFLOW"
57+
58+
cd $SRC/flac/
59+
make clean
60+
make -j$(nproc)
61+
62+
# Copy decoder fuzzers
63+
cd $SRC/flac/oss-fuzz
64+
cp fuzzer_decoder $OUT
5465
cp fuzzer_*.dict $OUT
5566
cd $SRC
67+
68+
# Build fuzzer_exo
5669
$CXX $CXXFLAGS -I $SRC/flac/include/ -I $SRC/ExoPlayer/extensions/flac/src/main/jni/ -I /usr/lib/jvm/java-11-openjdk-amd64/include/ -I /usr/lib/jvm/java-11-openjdk-amd64/include/linux/ fuzzer_exo.cpp \
5770
$SRC/flac/src/libFLAC++/.libs/libFLAC++.a $SRC/flac/src/libFLAC/.libs/libFLAC.a $SRC/libogg-install/lib/libogg.a $LIB_FUZZING_ENGINE -o $OUT/fuzzer_exo

0 commit comments

Comments
 (0)