Merge pull request #2226 from tmael/defectEVP

Verify input parameters of EVP_CipherFinal
This commit is contained in:
JacobBarthelmeh 2019-05-09 14:35:16 -06:00 committed by GitHub
commit e43e03c30a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -408,7 +408,9 @@ WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
unsigned char *out, int *outl)
{
int fl;
if (ctx == NULL || out == NULL) return BAD_FUNC_ARG;
if (ctx == NULL || out == NULL || outl == NULL || (*outl < 0))
return BAD_FUNC_ARG;
WOLFSSL_ENTER("wolfSSL_EVP_CipherFinal");
if (ctx->flags & WOLFSSL_EVP_CIPH_NO_PADDING) {
if (ctx->bufUsed != 0) return WOLFSSL_FAILURE;
@ -446,6 +448,10 @@ WOLFSSL_API int wolfSSL_EVP_CipherFinal(WOLFSSL_EVP_CIPHER_CTX *ctx,
*outl = fl;
} else return 0;
}
/* return error in cases where the block length is incorrect */
if (ctx->lastUsed == 0 && ctx->bufUsed == 0) {
return WOLFSSL_FAILURE;
}
}
return WOLFSSL_SUCCESS;
}