Merge pull request #2408 from dgarske/coverity

Minor fixes to resolve Coverity static analysis checks
This commit is contained in:
toddouska
2019-08-16 14:45:13 -07:00
committed by GitHub
3 changed files with 10 additions and 3 deletions

View File

@ -4260,14 +4260,18 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
WOLFSSL_MSG("Adding a CA"); WOLFSSL_MSG("Adding a CA");
if (cm == NULL) if (cm == NULL) {
FreeDer(pDer);
return BAD_FUNC_ARG; return BAD_FUNC_ARG;
}
#ifdef WOLFSSL_SMALL_STACK #ifdef WOLFSSL_SMALL_STACK
cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL, cert = (DecodedCert*)XMALLOC(sizeof(DecodedCert), NULL,
DYNAMIC_TYPE_DCERT); DYNAMIC_TYPE_DCERT);
if (cert == NULL) if (cert == NULL) {
FreeDer(pDer);
return MEMORY_E; return MEMORY_E;
}
#endif #endif
InitDecodedCert(cert, der->buffer, der->length, cm->heap); InitDecodedCert(cert, der->buffer, der->length, cm->heap);

View File

@ -4630,11 +4630,13 @@ int wc_ecc_sign_hash(const byte* in, word32 inlen, byte* out, word32 *outlen,
break; break;
} }
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)
/* if async pending then return and skip done cleanup below */ /* if async pending then return and skip done cleanup below */
if (err == WC_PENDING_E) { if (err == WC_PENDING_E) {
key->state++; key->state++;
return err; return err;
} }
#endif
/* cleanup */ /* cleanup */
#if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC) #if defined(WOLFSSL_ASYNC_CRYPT) && defined(WC_ASYNC_ENABLE_ECC)

View File

@ -425,7 +425,8 @@ void fp_mul_d(fp_int *a, fp_digit b, fp_int *c)
} }
/* zero any excess digits on the destination that we didn't write to */ /* zero any excess digits on the destination that we didn't write to */
for (; x < oldused; x++) { /* also checking FP_SIZE here for static analysis */
for (; x < oldused && x < FP_SIZE; x++) {
c->dp[x] = 0; c->dp[x] = 0;
} }
fp_clamp(c); fp_clamp(c);