From 641a9472f8bab01eb1594cdc89945a666a2b2d85 Mon Sep 17 00:00:00 2001 From: Martin Thomson Date: Thu, 10 Aug 2017 15:49:32 +1000 Subject: Bug 1388986 - Cleanup cloned projects before updating them, r=franziskus --- fuzz/config/git-copy.sh | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'fuzz') diff --git a/fuzz/config/git-copy.sh b/fuzz/config/git-copy.sh index a5c7d371d..a9e817e2a 100755 --- a/fuzz/config/git-copy.sh +++ b/fuzz/config/git-copy.sh @@ -7,18 +7,18 @@ if [ $# -lt 3 ]; then exit 2 fi -REPO=$1 -COMMIT=$2 -DIR=$3 +REPO="$1" +COMMIT="$2" +DIR="$3" echo "Copy '$COMMIT' from '$REPO' to '$DIR'" -if [ -f $DIR/.git-copy ]; then - CURRENT=$(cat $DIR/.git-copy) - if [ $(echo -n $COMMIT | wc -c) != "40" ]; then +if [ -f "$DIR"/.git-copy ]; then + CURRENT=$(cat "$DIR"/.git-copy) + if [ $(echo -n "$COMMIT" | wc -c) != "40" ]; then # On the off chance that $COMMIT is a remote head. - ACTUAL=$(git ls-remote $REPO $COMMIT | cut -c 1-40 -) + ACTUAL=$(git ls-remote "$REPO" "$COMMIT" | cut -c 1-40 -) else - ACTUAL=$COMMIT + ACTUAL="$COMMIT" fi if [ "$CURRENT" = "$ACTUAL" ]; then echo "Up to date." @@ -26,8 +26,9 @@ if [ -f $DIR/.git-copy ]; then fi fi -git init -q $DIR -git -C $DIR fetch -q --depth=1 $REPO $COMMIT:git-copy-tmp -git -C $DIR reset --hard git-copy-tmp -git -C $DIR rev-parse --verify HEAD > $DIR/.git-copy -rm -rf $DIR/.git +rm -rf "$DIR" +git init -q "$DIR" +git -C "$DIR" fetch -q --depth=1 "$REPO" "$COMMIT":git-copy-tmp +git -C "$DIR" reset --hard git-copy-tmp +git -C "$DIR" rev-parse --verify HEAD > "$DIR"/.git-copy +rm -rf "$DIR"/.git -- cgit v1.2.1 From 8059da8bd3a2f44edac7f6fa0817d97f25f69ad5 Mon Sep 17 00:00:00 2001 From: Franziskus Kiefer Date: Fri, 18 Aug 2017 10:11:07 +0200 Subject: Bug 1334106 - improve mpi fuzzing, r=me --- fuzz/mpi_expmod_target.cc | 4 ++++ fuzz/mpi_helper.cc | 6 ++++++ fuzz/mpi_helper.h | 1 + 3 files changed, 11 insertions(+) (limited to 'fuzz') diff --git a/fuzz/mpi_expmod_target.cc b/fuzz/mpi_expmod_target.cc index ed31da354..d61039dc7 100644 --- a/fuzz/mpi_expmod_target.cc +++ b/fuzz/mpi_expmod_target.cc @@ -19,6 +19,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { auto modulus = get_modulus(data, size, ctx); // Compare with OpenSSL exp mod m1 = &std::get<1>(modulus); + check_equal(A, &a, max_size); + check_equal(B, &b, max_size); + print_bn("A", A); + print_bn("B", B); assert(mp_exptmod(&a, &b, m1, &c) == MP_OKAY); (void)BN_mod_exp(C, A, B, std::get<0>(modulus), ctx); check_equal(C, &c, 2 * max_size); diff --git a/fuzz/mpi_helper.cc b/fuzz/mpi_helper.cc index 65cf4b9cd..d092fdb11 100644 --- a/fuzz/mpi_helper.cc +++ b/fuzz/mpi_helper.cc @@ -12,6 +12,12 @@ char *to_char(const uint8_t *x) { return reinterpret_cast(const_cast(x)); } +void print_bn(std::string label, BIGNUM *x) { + char *xc = BN_bn2hex(x); + std::cout << label << ": " << std::hex << xc << std::endl; + OPENSSL_free(xc); +} + // Check that the two numbers are equal. void check_equal(BIGNUM *b, mp_int *m, size_t max_size) { char *bnBc = BN_bn2hex(b); diff --git a/fuzz/mpi_helper.h b/fuzz/mpi_helper.h index 17383744b..ef7041b25 100644 --- a/fuzz/mpi_helper.h +++ b/fuzz/mpi_helper.h @@ -23,6 +23,7 @@ void parse_input(const uint8_t *data, size_t size, BIGNUM *A, BIGNUM *B, void parse_input(const uint8_t *data, size_t size, BIGNUM *A, mp_int *a); std::tuple get_modulus(const uint8_t *data, size_t size, BN_CTX *ctx); +void print_bn(std::string label, BIGNUM *x); // Initialise MPI and BN variables // XXX: Also silence unused variable warnings for R. -- cgit v1.2.1 From 42927a6dcfb8fdc49db07f7c6ccef9d203d0f9d5 Mon Sep 17 00:00:00 2001 From: Franziskus Kiefer Date: Sun, 20 Aug 2017 21:57:59 +0200 Subject: Bug 1334106 - improve mpi fuzzing, r=bustage --- fuzz/mpi_expmod_target.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fuzz') diff --git a/fuzz/mpi_expmod_target.cc b/fuzz/mpi_expmod_target.cc index d61039dc7..d1ce7e6b2 100644 --- a/fuzz/mpi_expmod_target.cc +++ b/fuzz/mpi_expmod_target.cc @@ -21,8 +21,10 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { m1 = &std::get<1>(modulus); check_equal(A, &a, max_size); check_equal(B, &b, max_size); + check_equal(std::get<0>(modulus), m1, max_size); print_bn("A", A); print_bn("B", B); + print_bn("m", std::get<0>(modulus)); assert(mp_exptmod(&a, &b, m1, &c) == MP_OKAY); (void)BN_mod_exp(C, A, B, std::get<0>(modulus), ctx); check_equal(C, &c, 2 * max_size); -- cgit v1.2.1 From 23d31796efb88463080404bad96ea78ea1a25020 Mon Sep 17 00:00:00 2001 From: Franziskus Kiefer Date: Mon, 21 Aug 2017 07:16:17 +0200 Subject: Bug 1334106 - improve mpi fuzzing, r=bustage --- fuzz/mpi_expmod_target.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fuzz') diff --git a/fuzz/mpi_expmod_target.cc b/fuzz/mpi_expmod_target.cc index d1ce7e6b2..23826e935 100644 --- a/fuzz/mpi_expmod_target.cc +++ b/fuzz/mpi_expmod_target.cc @@ -19,12 +19,12 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { auto modulus = get_modulus(data, size, ctx); // Compare with OpenSSL exp mod m1 = &std::get<1>(modulus); - check_equal(A, &a, max_size); - check_equal(B, &b, max_size); - check_equal(std::get<0>(modulus), m1, max_size); print_bn("A", A); print_bn("B", B); print_bn("m", std::get<0>(modulus)); + check_equal(A, &a, max_size); + check_equal(B, &b, max_size); + check_equal(std::get<0>(modulus), m1, 3 * max_size); assert(mp_exptmod(&a, &b, m1, &c) == MP_OKAY); (void)BN_mod_exp(C, A, B, std::get<0>(modulus), ctx); check_equal(C, &c, 2 * max_size); -- cgit v1.2.1