File: oss-fuzz-build.sh

package info (click to toggle)
libreoffice 1:6.1.5-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,699,584 kB
  • sloc: cpp: 4,078,558; xml: 324,485; java: 281,935; python: 48,236; ansic: 36,476; perl: 32,383; sh: 13,671; yacc: 10,820; makefile: 9,085; cs: 6,600; lex: 2,184; objc: 1,904; awk: 978; pascal: 949; asm: 866; php: 79; csh: 20; sed: 5
file content (49 lines) | stat: -rwxr-xr-x 1,607 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash -e

if [ -z "${OUT}" ] || [ -z "${SRC}" ] || [ -z "${WORK}" ]; then
    echo "OUT, SRC or WORK not set - script expects to be called inside oss-fuzz build env"
    exit 1
fi

#shuffle CXXFLAGS -stdlib=libc++ arg into CXX as well because we use
#the CXX as the linker and need to pass -stdlib=libc++ to build
export CXX="$CXX -stdlib=libc++ -fsanitize-blacklist=$SRC/libreoffice/bin/sanitize-blacklist.txt"
#similarly force the -fsanitize etc args in as well as pthread to get
#things to link successfully during the build
export LDFLAGS="$CFLAGS -lpthread"

cd $WORK
$SRC/libreoffice/autogen.sh --with-distro=LibreOfficeOssFuzz --with-external-tar=$SRC

#build-time rsc tool leaks a titch
export ASAN_OPTIONS="detect_leaks=0"

make fuzzers

pushd instdir/program
head -c -14 services.rdb  > templateservices.rdb
tail -c +85 ./services/services.rdb >> templateservices.rdb
for a in *fuzzer; do
    #some minimal fonts required
    cp $a $OUT
    mkdir -p $OUT/$a.fonts
    cp $SRC/libreoffice/extras/source/truetype/symbol/opens___.ttf ../share/fonts/truetype/Liberation* $OUT/$a.fonts
    #minimal runtime requirements
    cp templateservices.rdb $OUT/$a.services.rdb
    cp types.rdb $OUT/$a.types.rdb
    cp types/offapi.rdb $OUT/$a.moretypes.rdb
    cat > $OUT/$a.unorc << EOF
[Bootstrap]
URE_INTERNAL_LIB_DIR=\${ORIGIN}
UNO_TYPES=\${ORIGIN}/$a.types.rdb \${ORIGIN}/$a.moretypes.rdb
UNO_SERVICES=\${ORIGIN}/$a.services.rdb
EOF
done
popd

#starting corpuses
cp $SRC/*_seed_corpus.zip $OUT
#fuzzing dictionaries
cp $SRC/*.dict $OUT
#options files
cp $SRC/libreoffice/vcl/workben/*.options $OUT