Version 6.1.4.1, tag libreoffice-6.1.4.1
[LibreOffice.git] / bin / oss-fuzz-build.sh
blob08330daffe2b6116a535dfacf3ead7595d96e2e8
1 #!/bin/bash -e
3 if [ -z "${OUT}" ] || [ -z "${SRC}" ] || [ -z "${WORK}" ]; then
4 echo "OUT, SRC or WORK not set - script expects to be called inside oss-fuzz build env"
5 exit 1
6 fi
8 #shuffle CXXFLAGS -stdlib=libc++ arg into CXX as well because we use
9 #the CXX as the linker and need to pass -stdlib=libc++ to build
10 export CXX="$CXX -stdlib=libc++ -fsanitize-blacklist=$SRC/libreoffice/bin/sanitize-blacklist.txt"
11 #similarly force the -fsanitize etc args in as well as pthread to get
12 #things to link successfully during the build
13 export LDFLAGS="$CFLAGS -lpthread"
15 cd $WORK
16 $SRC/libreoffice/autogen.sh --with-distro=LibreOfficeOssFuzz --with-external-tar=$SRC
18 #build-time rsc tool leaks a titch
19 export ASAN_OPTIONS="detect_leaks=0"
21 make fuzzers
23 pushd instdir/program
24 head -c -14 services.rdb > templateservices.rdb
25 tail -c +85 ./services/services.rdb >> templateservices.rdb
26 for a in *fuzzer; do
27 #some minimal fonts required
28 cp $a $OUT
29 mkdir -p $OUT/$a.fonts
30 cp $SRC/libreoffice/extras/source/truetype/symbol/opens___.ttf ../share/fonts/truetype/Liberation* $OUT/$a.fonts
31 #minimal runtime requirements
32 cp templateservices.rdb $OUT/$a.services.rdb
33 cp types.rdb $OUT/$a.types.rdb
34 cp types/offapi.rdb $OUT/$a.moretypes.rdb
35 cat > $OUT/$a.unorc << EOF
36 [Bootstrap]
37 URE_INTERNAL_LIB_DIR=\${ORIGIN}
38 UNO_TYPES=\${ORIGIN}/$a.types.rdb \${ORIGIN}/$a.moretypes.rdb
39 UNO_SERVICES=\${ORIGIN}/$a.services.rdb
40 EOF
41 done
42 popd
44 #starting corpuses
45 cp $SRC/*_seed_corpus.zip $OUT
46 #fuzzing dictionaries
47 cp $SRC/*.dict $OUT
48 #options files
49 cp $SRC/libreoffice/vcl/workben/*.options $OUT