Fix for coverity report with possible use of uninitialized value "err" in WC_ECC_NONBLOCK case. More fixes for building with WOLFSSL_NO_MALLOC.

This commit is contained in:
David Garske
2020-11-11 16:25:21 -08:00
parent 40387ab0a0
commit e5a0a264b3
2 changed files with 7 additions and 3 deletions

View File

@@ -6359,6 +6359,7 @@ int wc_ecc_verify_hash_ex(mp_int *r, mp_int *s, const byte* hash,
/* perform blocking call to non-blocking function */
ecc_nb_ctx_t nb_ctx;
XMEMSET(&nb_ctx, 0, sizeof(nb_ctx));
err = NOT_COMPILED_IN; /* set default error */
#endif
#ifndef WOLFSSL_SP_NO_256
if (ecc_sets[key->idx].id == ECC_SECP256R1) {

View File

@@ -21393,7 +21393,7 @@ exit:
}
#endif /* WOLFSSL_CERT_GEN */
#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) && !defined(WOLFSSL_NO_MALLOC)
/* Test for the wc_ecc_key_new() and wc_ecc_key_free() functions. */
static int ecc_test_allocator(WC_RNG* rng)
{
@@ -21993,10 +21993,11 @@ static int ecc_test(void)
goto done;
}
#endif
#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) && !defined(HAVE_SELFTEST) && !defined(WOLFSSL_NO_MALLOC)
ret = ecc_test_allocator(&rng);
if (ret != 0) {
printf("ecc_test_allocator failed!: %d\n", ret);
goto done;
}
#endif
@@ -22005,6 +22006,7 @@ static int ecc_test(void)
ret = ecc_test_nonblock(&rng);
if (ret != 0) {
printf("ecc_test_nonblock failed!: %d\n", ret);
goto done;
}
#endif
@@ -22217,7 +22219,8 @@ done:
#if defined(USE_CERT_BUFFERS_256) && !defined(WOLFSSL_ATECC508A) && \
!defined(WOLFSSL_ATECC608A) && !defined(NO_ECC256) && \
defined(HAVE_ECC_VERIFY) && defined(HAVE_ECC_SIGN)
static int ecc_test_buffers(void) {
static int ecc_test_buffers(void)
{
size_t bytes;
#ifdef WOLFSSL_SMALL_STACK
ecc_key *cliKey = (ecc_key *)XMALLOC(sizeof *cliKey, HEAP_HINT, DYNAMIC_TYPE_TMP_BUFFER);