Skip to content

Commit

Permalink
Bug 1345368 - land NSS 6fafb8fd9ff4, r=me
Browse files Browse the repository at this point in the history
  • Loading branch information
franziskuskiefer committed Mar 8, 2017
1 parent 914bd49 commit 6e7f901
Show file tree
Hide file tree
Showing 19 changed files with 62,618 additions and 66 deletions.
2 changes: 1 addition & 1 deletion security/nss/TAG-INFO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dec8c06d7ed9
6fafb8fd9ff4
49 changes: 9 additions & 40 deletions security/nss/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,7 @@ source "$cwd"/coreconf/sanitizers.sh
# Usage info
show_help()
{
cat << EOF
Usage: ${0##*/} [-hcv] [-j <n>] [--nspr] [--gyp|-g] [--opt|-o] [-m32]
[--test] [--pprof] [--scan-build[=output]] [--ct-verif]
[--asan] [--ubsan] [--msan] [--sancov[=edge|bb|func|...]]
[--disable-tests] [--fuzz[=tls|oss]]
This script builds NSS with gyp and ninja.
This build system is still under development. It does not yet support all
the features or platforms that NSS supports.
NSS build tool options:
-h display this help and exit
-c clean before build
-v verbose build
-j <n> run at most <n> concurrent jobs
--nspr force a rebuild of NSPR
--gyp|-g force a rerun of gyp
--opt|-o do an opt build
-m32 do a 32-bit build on a 64-bit system
--test ignore map files and export everything we have
--fuzz build fuzzing targets (this always enables test builds)
--fuzz=tls to enable TLS fuzzing mode
--fuzz=oss to build for OSS-Fuzz
--pprof build with gperftool support
--ct-verif build with valgrind for ct-verif
--scan-build run the build with scan-build (scan-build has to be in the path)
--scan-build=/out/path sets the output path for scan-build
--asan do an asan build
--ubsan do an ubsan build
--ubsan=bool,shift,... sets specific UB sanitizers
--msan do an msan build
--sancov do sanitize coverage builds
--sancov=func sets coverage to function level for example
--disable-tests don't build tests and corresponding cmdline utils
EOF
cat "$cwd"/help.txt
}

run_verbose()
Expand Down Expand Up @@ -84,6 +48,7 @@ verbose=0
fuzz=0
fuzz_tls=0
fuzz_oss=0
no_local_nspr=0

gyp_params=(--depth="$cwd" --generator-output=".")
nspr_params=()
Expand Down Expand Up @@ -121,6 +86,9 @@ while [ $# -gt 0 ]; do
--ct-verif) gyp_params+=(-Dct_verif=1) ;;
--disable-tests) gyp_params+=(-Ddisable_tests=1) ;;
--no-zdefs) gyp_params+=(-Dno_zdefs=1) ;;
--system-sqlite) gyp_params+=(-Duse_system_sqlite=1) ;;
--with-nspr=?*) set_nspr_path "${1#*=}"; no_local_nspr=1 ;;
--system-nspr) set_nspr_path "/usr/include/nspr/:"; no_local_nspr=1 ;;
*) show_help; exit 2 ;;
esac
shift
Expand Down Expand Up @@ -207,7 +175,7 @@ fi
mkdir -p "$dist_dir"
echo $target > "$dist_dir"/latest

if [ "$rebuild_nspr" = 1 ]; then
if [[ "$rebuild_nspr" = 1 && "$no_local_nspr" = 0 ]]; then
nspr_build "${nspr_params[@]}"
mv -f "$nspr_config".new "$nspr_config"
fi
Expand All @@ -216,8 +184,9 @@ if [ "$rebuild_gyp" = 1 ]; then
# These extra arguments aren't used in determining whether to rebuild.
obj_dir="$dist_dir"/$target
gyp_params+=(-Dnss_dist_obj_dir=$obj_dir)
gyp_params+=(-Dnspr_lib_dir=$obj_dir/lib)
gyp_params+=(-Dnspr_include_dir=$obj_dir/include/nspr)
if [ "$no_local_nspr" = 0 ]; then
set_nspr_path "$obj_dir/include/nspr:$obj_dir/lib"
fi

run_verbose run_scanbuild gyp -f ninja "${gyp_params[@]}" "$cwd"/nss.gyp

Expand Down
10 changes: 5 additions & 5 deletions security/nss/cmd/modutil/pk11.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static char *disableReasonStr[] = {
"could not verify token",
"token not present"
};
static int numDisableReasonStr =
static size_t numDisableReasonStr =
sizeof(disableReasonStr) / sizeof(disableReasonStr[0]);

/***********************************************************************
Expand All @@ -513,7 +513,7 @@ ListModule(char *moduleName)
CK_SLOT_INFO slotinfo;
CK_TOKEN_INFO tokeninfo;
char *ciphers, *mechanisms;
PK11DisableReasons reason;
size_t reasonIdx;
Error rv = SUCCESS;

if (!moduleName) {
Expand Down Expand Up @@ -604,10 +604,10 @@ ListModule(char *moduleName)
PR_fprintf(PR_STDOUT, PAD "Firmware Version: %d.%d\n",
slotinfo.firmwareVersion.major, slotinfo.firmwareVersion.minor);
if (PK11_IsDisabled(slot)) {
reason = PK11_GetDisabledReason(slot);
if (reason < numDisableReasonStr) {
reasonIdx = PK11_GetDisabledReason(slot);
if (reasonIdx < numDisableReasonStr) {
PR_fprintf(PR_STDOUT, PAD "Status: DISABLED (%s)\n",
disableReasonStr[reason]);
disableReasonStr[reasonIdx]);
} else {
PR_fprintf(PR_STDOUT, PAD "Status: DISABLED\n");
}
Expand Down
1 change: 0 additions & 1 deletion security/nss/coreconf/coreconf.dep
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@
*/

#error "Do not include this header file."

8 changes: 8 additions & 0 deletions security/nss/coreconf/nspr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,11 @@ nspr_clean()
{
rm -rf "$cwd"/../nspr/$target
}

set_nspr_path()
{
local include=$(echo "$1" | cut -d: -f1)
local lib=$(echo "$1" | cut -d: -f2)
gyp_params+=(-Dnspr_include_dir="$include")
gyp_params+=(-Dnspr_lib_dir="$lib")
}
8 changes: 6 additions & 2 deletions security/nss/gtests/common/gtests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
int main(int argc, char **argv) {
::testing::InitGoogleTest(&argc, argv);

NSS_NoDB_Init(nullptr);
NSS_SetDomesticPolicy();
if (NSS_NoDB_Init(nullptr) != SECSuccess) {
return 1;
}
if (NSS_SetDomesticPolicy() != SECSuccess) {
return 1;
}
int rv = RUN_ALL_TESTS();

if (NSS_Shutdown() != SECSuccess) {
Expand Down
23 changes: 22 additions & 1 deletion security/nss/gtests/freebl_gtest/freebl_gtest.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,28 @@
],
}],
],
}
},
{
'target_name': 'prng_gtest',
'type': 'executable',
'sources': [
'prng_kat_unittest.cc',
],
'dependencies': [
'<(DEPTH)/exports.gyp:nss_exports',
'<(DEPTH)/lib/util/util.gyp:nssutil3',
'<(DEPTH)/gtests/google_test/google_test.gyp:gtest',
'<(DEPTH)/lib/nss/nss.gyp:nss_static',
'<(DEPTH)/lib/pk11wrap/pk11wrap.gyp:pk11wrap_static',
'<(DEPTH)/lib/cryptohi/cryptohi.gyp:cryptohi',
'<(DEPTH)/lib/certhigh/certhigh.gyp:certhi',
'<(DEPTH)/lib/certdb/certdb.gyp:certdb',
'<(DEPTH)/lib/base/base.gyp:nssb',
'<(DEPTH)/lib/dev/dev.gyp:nssdev',
'<(DEPTH)/lib/pki/pki.gyp:nsspki',
'<(DEPTH)/lib/ssl/ssl.gyp:ssl',
],
},
],
'target_defaults': {
'include_dirs': [
Expand Down
Loading

0 comments on commit 6e7f901

Please sign in to comment.