fix clang/scan-build warnings for PKCS7

This commit is contained in:
Chris Conlon 2017-04-17 14:23:37 -06:00
parent 4f26e0341b
commit bab3fd5925
2 changed files with 13 additions and 15 deletions

View File

@ -451,7 +451,7 @@ static int wc_PKCS7_RsaSign(PKCS7* pkcs7, byte* in, word32 inSz, ESD* esd)
#endif
if (pkcs7 == NULL || pkcs7->privateKey == NULL || pkcs7->rng == NULL ||
in == NULL || esd == NULL || esd->encContentDigest == NULL)
in == NULL || esd == NULL)
return BAD_FUNC_ARG;
#ifdef WOLFSSL_SMALL_STACK
@ -500,7 +500,7 @@ static int wc_PKCS7_EcdsaSign(PKCS7* pkcs7, byte* in, word32 inSz, ESD* esd)
#endif
if (pkcs7 == NULL || pkcs7->privateKey == NULL || pkcs7->rng == NULL ||
in == NULL || esd == NULL || esd->encContentDigest == NULL)
in == NULL || esd == NULL)
return BAD_FUNC_ARG;
#ifdef WOLFSSL_SMALL_STACK
@ -559,7 +559,7 @@ static int wc_PKCS7_BuildSignedAttributes(PKCS7* pkcs7, ESD* esd)
PKCS7Attrib cannedAttribs[2];
word32 cannedAttribsCount;
if (pkcs7 == NULL || esd == NULL || &esd->hash == NULL)
if (pkcs7 == NULL || esd == NULL)
return BAD_FUNC_ARG;
hashSz = wc_HashGetDigestSize(esd->hashType);
@ -672,9 +672,8 @@ static int wc_PKCS7_BuildDigestInfo(PKCS7* pkcs7, byte* flatSignedAttribs,
word32 digestInfoSeqSz, digestStrSz, algoIdSz;
word32 attribSetSz;
if (pkcs7 == NULL || esd == NULL || &esd->hash == NULL ||
esd->contentDigest == NULL || esd->signerDigAlgoId == NULL ||
digestInfo == NULL || digestInfoSz == NULL) {
if (pkcs7 == NULL || esd == NULL || digestInfo == NULL ||
digestInfoSz == NULL) {
return BAD_FUNC_ARG;
}
@ -764,7 +763,7 @@ static int wc_PKCS7_SignedDataBuildSignature(PKCS7* pkcs7,
byte digestInfo[digestInfoSz];
#endif
if (pkcs7 == NULL || esd == NULL || esd->contentAttribsDigest == NULL)
if (pkcs7 == NULL || esd == NULL)
return BAD_FUNC_ARG;
#ifdef WOLFSSL_SMALL_STACK
@ -1114,7 +1113,7 @@ int wc_PKCS7_EncodeSignedData(PKCS7* pkcs7, byte* output, word32 outputSz)
idx += esd->signerDigAlgoIdSz;
/* SignerInfo:Attributes */
if (pkcs7->signedAttribsSz != 0) {
if (flatSignedAttribsSz > 0) {
XMEMCPY(output + idx, esd->signedAttribSet, esd->signedAttribSetSz);
idx += esd->signedAttribSetSz;
XMEMCPY(output + idx, flatSignedAttribs, flatSignedAttribsSz);
@ -1156,8 +1155,7 @@ static int wc_PKCS7_RsaVerify(PKCS7* pkcs7, byte* sig, int sigSz,
RsaKey* key = &stack_key;
#endif
if (pkcs7 == NULL || pkcs7->publicKey == NULL ||
sig == NULL || hash == NULL) {
if (pkcs7 == NULL || sig == NULL || hash == NULL) {
return BAD_FUNC_ARG;
}
@ -1234,7 +1232,7 @@ static int wc_PKCS7_EcdsaVerify(PKCS7* pkcs7, byte* sig, int sigSz,
ecc_key* key = &stack_key;
#endif
if (pkcs7 == NULL || pkcs7->publicKey == NULL || sig == NULL)
if (pkcs7 == NULL || sig == NULL)
return BAD_FUNC_ARG;
#ifdef WOLFSSL_SMALL_STACK

View File

@ -12205,7 +12205,7 @@ static int pkcs7_load_certs_keys(byte* rsaCert, word32* rsaCertSz,
if (!certFile)
return -203;
*rsaCertSz = fread(rsaCert, 1, *rsaCertSz, certFile);
*rsaCertSz = (word32)fread(rsaCert, 1, *rsaCertSz, certFile);
fclose(certFile);
#endif
@ -12226,7 +12226,7 @@ static int pkcs7_load_certs_keys(byte* rsaCert, word32* rsaCertSz,
if (!keyFile)
return -204;
*rsaPrivKeySz = fread(rsaPrivKey, 1, *rsaPrivKeySz, keyFile);
*rsaPrivKeySz = (word32)fread(rsaPrivKey, 1, *rsaPrivKeySz, keyFile);
fclose(keyFile);
#endif /* USE_CERT_BUFFERS */
@ -12246,7 +12246,7 @@ static int pkcs7_load_certs_keys(byte* rsaCert, word32* rsaCertSz,
if (!certFile)
return -207;
*eccCertSz = fread(eccCert, 1, *eccCertSz, certFile);
*eccCertSz = (word32)fread(eccCert, 1, *eccCertSz, certFile);
fclose(certFile);
#endif /* USE_CERT_BUFFERS_256 */
@ -12261,7 +12261,7 @@ static int pkcs7_load_certs_keys(byte* rsaCert, word32* rsaCertSz,
if (!keyFile)
return -208;
*eccPrivKeySz = fread(eccPrivKey, 1, *eccPrivKeySz, keyFile);
*eccPrivKeySz = (word32)fread(eccPrivKey, 1, *eccPrivKeySz, keyFile);
fclose(keyFile);
#endif /* USE_CERT_BUFFERS_256 */
#endif /* HAVE_ECC */