Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EVP_*Update: ensure that input NULL with length 0 isn't passed #8676

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions crypto/evp/evp_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,12 @@ static int evp_EncryptDecryptUpdate(EVP_CIPHER_CTX *ctx,
bl = ctx->cipher->block_size;

if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
/* Prevent accidental "final" call */
if (inl <= 0 && in == NULL) {
levitte marked this conversation as resolved.
Show resolved Hide resolved
*outl = 0;
return inl == 0;
}

/* If block size > 1 then the cipher will have to do this check */
if (bl == 1 && is_partially_overlapping(out, in, cmpl)) {
EVPerr(EVP_F_EVP_ENCRYPTDECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);
Expand Down Expand Up @@ -458,6 +464,12 @@ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl,
cmpl = (cmpl + 7) / 8;

if (ctx->cipher->flags & EVP_CIPH_FLAG_CUSTOM_CIPHER) {
/* Prevent accidental "final" call */
if (inl <= 0 && in == NULL) {
*outl = 0;
return inl == 0;
}

if (b == 1 && is_partially_overlapping(out, in, cmpl)) {
EVPerr(EVP_F_EVP_DECRYPTUPDATE, EVP_R_PARTIALLY_OVERLAPPING);
return 0;
Expand Down