Skip to content

Commit

Permalink
Tolerate 0 byte input length for Update functions
Browse files Browse the repository at this point in the history
We treat that as automatic success. Other EVP_*Update functions already do
this (e.g. EVP_EncryptUpdate, EVP_DecryptUpdate etc). EVP_EncodeUpdate is
a bit of an anomoly. That treats 0 byte input length as an error.

Fixes openssl#8576
  • Loading branch information
mattcaswell committed Mar 26, 2019
1 parent 866cc23 commit d92e681
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crypto/evp/digest.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, ENGINE *impl)

int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *data, size_t count)
{
if (count == 0)
return 1;

if (ctx->digest == NULL || ctx->digest->prov == NULL)
goto legacy;

Expand Down
2 changes: 2 additions & 0 deletions crypto/evp/mac_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ int EVP_MAC_init(EVP_MAC_CTX *ctx)

int EVP_MAC_update(EVP_MAC_CTX *ctx, const unsigned char *data, size_t datalen)
{
if (datalen == 0)
return 1;
return ctx->meth->update(ctx->data, data, datalen);
}

Expand Down

0 comments on commit d92e681

Please sign in to comment.