2016-10-11 09:42:13 +00:00
|
|
|
#!/bin/bash -eu
|
|
|
|
# Copyright 2016 Google Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# Build the library.
|
2016-11-07 13:34:30 +00:00
|
|
|
make CCC="$CXX" XCFLAGS="$CXXFLAGS" SANITIZER_CFLAGS="$CXXFLAGS" \
|
|
|
|
BUILD_OPT=1 USE_64=1 NSS_DISABLE_GTESTS=1 ZDEFS_FLAG= \
|
|
|
|
nss_clean_all nss_build_all
|
2016-10-11 09:42:13 +00:00
|
|
|
cd ..
|
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
# Copy libraries and some objects to $WORK/nss/lib.
|
|
|
|
mkdir -p $WORK/nss/lib
|
|
|
|
cp dist/Linux*/lib/*.a $WORK/nss/lib
|
|
|
|
cp nspr/Linux*/pr/src/misc/prlog2.o $WORK/nss/lib
|
2016-10-11 09:42:13 +00:00
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
# Copy includes to $WORK/nss/include.
|
|
|
|
mkdir -p $WORK/nss/include
|
|
|
|
cp -rL dist/Linux*/include/* $WORK/nss/include
|
|
|
|
cp -rL dist/{public,private}/nss/* $WORK/nss/include
|
2016-10-11 09:42:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Build the fuzzers.
|
|
|
|
FUZZERS="asn1_algorithmid_fuzzer \
|
|
|
|
asn1_any_fuzzer \
|
|
|
|
asn1_bitstring_fuzzer \
|
|
|
|
asn1_bmpstring_fuzzer \
|
|
|
|
asn1_boolean_fuzzer \
|
|
|
|
asn1_generalizedtime_fuzzer \
|
|
|
|
asn1_ia5string_fuzzer \
|
|
|
|
asn1_integer_fuzzer \
|
|
|
|
asn1_null_fuzzer \
|
|
|
|
asn1_objectid_fuzzer \
|
|
|
|
asn1_octetstring_fuzzer \
|
|
|
|
asn1_utctime_fuzzer \
|
|
|
|
asn1_utf8string_fuzzer"
|
|
|
|
|
|
|
|
# The following fuzzers are currently disabled due to linking issues:
|
|
|
|
# cert_certificate_fuzzer, seckey_privatekeyinfo_fuzzer
|
|
|
|
|
|
|
|
|
|
|
|
for fuzzer in $FUZZERS; do
|
2016-11-18 19:16:38 +00:00
|
|
|
$CXX $CXXFLAGS -std=c++11 $SRC/$fuzzer.cc \
|
|
|
|
-I$WORK/nss/include \
|
2016-12-07 19:41:08 +00:00
|
|
|
-lFuzzingEngine \
|
2016-11-18 19:16:38 +00:00
|
|
|
$WORK/nss/lib/libnss.a $WORK/nss/lib/libnssutil.a \
|
|
|
|
$WORK/nss/lib/libnspr4.a $WORK/nss/lib/libplc4.a $WORK/nss/lib/libplds4.a \
|
2016-11-18 19:45:51 +00:00
|
|
|
$WORK/nss/lib/prlog2.o -o $OUT/$fuzzer
|
2016-10-11 09:42:13 +00:00
|
|
|
done
|
2016-11-04 23:47:14 +00:00
|
|
|
|
2016-11-18 19:16:38 +00:00
|
|
|
# Archive and copy to $OUT seed corpus if the build succeeded.
|
|
|
|
zip $WORK/nss/all_nss_seed_corpus.zip $SRC/nss-corpus/*/*
|
2016-11-04 23:47:14 +00:00
|
|
|
|
|
|
|
for fuzzer in $FUZZERS; do
|
2016-11-18 19:16:38 +00:00
|
|
|
cp $WORK/nss/all_nss_seed_corpus.zip $OUT/${fuzzer}_seed_corpus.zip
|
2016-11-04 23:47:14 +00:00
|
|
|
done
|