diff options
author | Jonas Maebe <jonas.maebe@elis.ugent.be> | 2013-12-08 18:10:50 +0100 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2014-08-17 18:52:14 +0200 |
commit | 771e0c6c7a7f738a31b5015c1cabb867dcbb80c1 (patch) | |
tree | 08e15d47c1929d6079e6ebf9a1bfdb2e7af575a4 | |
parent | d8513b4abd00b89481cba59dd3d7f81b90a2e747 (diff) |
dev_crypto_md5_update: check result of realloc(md_data->data) and don't leak memory if it fails
Signed-off-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
-rw-r--r-- | crypto/evp/openbsd_hw.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/crypto/evp/openbsd_hw.c b/crypto/evp/openbsd_hw.c index 0554019489..78ad707ad8 100644 --- a/crypto/evp/openbsd_hw.c +++ b/crypto/evp/openbsd_hw.c @@ -382,11 +382,15 @@ static int dev_crypto_md5_update(EVP_MD_CTX *ctx,const void *data, unsigned long len) { MD_DATA *md_data=ctx->md_data; + char *tmp_md_data; if(ctx->flags&EVP_MD_CTX_FLAG_ONESHOT) return do_digest(md_data->sess.ses,md_data->md,data,len); - md_data->data=OPENSSL_realloc(md_data->data,md_data->len+len); + tmp_md_data=OPENSSL_realloc(md_data->data,md_data->len+len); + if (tmp_md_data == NULL) + return 0; + md_data->data=tmp_md_data; memcpy(md_data->data+md_data->len,data,len); md_data->len+=len; |