summaryrefslogtreecommitdiff
path: root/.travis/fuzz-linux-asan
blob: af8a08c0c34542b0bf735393f5285f4f6b2e8a91 (plain)
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
50
51
52
53
54
55
56
57
58
59
#!/bin/sh -eux

${CC} --version

FAKEROOT=/fakeroot
sudo mkdir ${FAKEROOT}
sudo chmod 755 ${FAKEROOT}

# Build and install libcbor.
git clone git://github.com/pjk/libcbor
cd libcbor
patch -p0 < ../fuzz/README
mkdir build
cd build
cmake -DCMAKE_C_FLAGS_DEBUG="-g2 -fno-omit-frame-pointer" \
	-DCMAKE_C_COMPILER=clang -DCMAKE_BUILD_TYPE=Debug \
	-DCMAKE_INSTALL_PREFIX=${FAKEROOT} -DSANITIZE=ON \
	-DCMAKE_INSTALL_LIBDIR=lib ..
make
sudo make install
cd ../..

# Build and install OpenSSL 1.1.1b.
git clone git://github.com/openssl/openssl
cd openssl
git checkout OpenSSL_1_1_1b
./Configure linux-x86_64-clang enable-asan --prefix=${FAKEROOT} \
	 --openssldir=${FAKEROOT}/openssl
make clean
make
sudo make install_sw
cd ..

# Build libfido2.
mkdir build
cd build
export PKG_CONFIG_PATH=/fakeroot/lib/pkgconfig
cmake -DFUZZ=1 -DLIBFUZZER=1 -DASAN=1 -DUBSAN=1 -DCMAKE_C_COMPILER=clang \
	-DCRYPTO_INCLUDE_DIRS=${FAKEROOT}/include \
        -DCRYPTO_LIBRARY_DIRS=${FAKEROOT}/lib \
        -DCBOR_INCLUDE_DIRS=${FAKEROOT}/include \
        -DCBOR_LIBRARY_DIRS=${FAKEROOT}/lib \
        -DCMAKE_BUILD_TYPE=Debug ..
make

# Fuzz with ASAN.
mkdir corpus
curl -s https://ambientworks.net/tmp/corpus.tgz > ../fuzz/corpus.tgz
tar -C corpus -zxf ../fuzz/corpus.tgz
fuzz/fuzz_cred -use_value_profile=1 -reload=30 -print_pcs=1 \
	-print_funcs=30 -timeout=10 -runs=1 corpus/fuzz_cred
fuzz/fuzz_assert -use_value_profile=1 -reload=30 -print_pcs=1 \
	-print_funcs=30 -timeout=10 -runs=1 corpus/fuzz_assert
fuzz/fuzz_credman -use_value_profile=1 -reload=30 -print_pcs=1 \
	-print_funcs=30 -timeout=10 -runs=1 corpus/fuzz_credman
fuzz/fuzz_mgmt -use_value_profile=1 -reload=30 -print_pcs=1 \
	-print_funcs=30 -timeout=10 -runs=1 corpus/fuzz_mgmt
fuzz/fuzz_bio -use_value_profile=1 -reload=30 -print_pcs=1 \
	-print_funcs=30 -timeout=10 -runs=1 corpus/fuzz_bio