Skip to content

Commit

Permalink
Merge bitcoin#889: fix uninitialized read in tests
Browse files Browse the repository at this point in the history
99a1cfe print warnings for conditional-uninitialized (PiRK)
3d2cf6c initialize variable in tests (PiRK)

Pull request description:

ACKs for top commit:
  real-or-random:
    ACK 99a1cfe code inspection
  jonasnick:
    ACK 99a1cfe

Tree-SHA512: 72f92f51c44210ab54f166920f540525db0e3d1f19a2fa56e4a6d157a38a582f9dc649d919cf3278482c9fd723021b07759284a8fccbc574b62a22aac0facf51
  • Loading branch information
jonasnick committed Apr 7, 2021
2 parents c083cc6 + 99a1cfe commit 1e5d50f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 9 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
CFLAGS="$saved_CFLAGS"
])

saved_CFLAGS="$CFLAGS"
CFLAGS="-Wconditional-uninitialized $CFLAGS"
AC_MSG_CHECKING([if ${CC} supports -Wconditional-uninitialized])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
[ AC_MSG_RESULT([yes]) ],
[ AC_MSG_RESULT([no])
CFLAGS="$saved_CFLAGS"
])

saved_CFLAGS="$CFLAGS"
CFLAGS="-fvisibility=hidden $CFLAGS"
AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Expand Down
4 changes: 3 additions & 1 deletion src/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -4526,8 +4526,10 @@ void test_ecdsa_sign_verify(void) {
secp256k1_scalar one;
secp256k1_scalar msg, key;
secp256k1_scalar sigr, sigs;
int recid;
int getrec;
/* Initialize recid to suppress a false positive -Wconditional-uninitialized in clang.
VG_UNDEF ensures that valgrind will still treat the variable as uninitialized. */
int recid = -1; VG_UNDEF(&recid, sizeof(recid));
random_scalar_order_test(&msg);
random_scalar_order_test(&key);
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &pubj, &key);
Expand Down

0 comments on commit 1e5d50f

Please sign in to comment.