diff options
author | Jonas Maebe <jonas.maebe@elis.ugent.be> | 2013-12-08 17:20:30 +0100 |
---|---|---|
committer | Kurt Roeckx <kurt@roeckx.be> | 2014-08-15 22:38:51 +0200 |
commit | d6f69ae5475f514ca6f81360ac8adafe1294a2c6 (patch) | |
tree | 4bb3ba8c36fb0ff9f42303edd88aa534257131de | |
parent | 349e6b2b0aea737422fedfa28467bed5571ead2a (diff) |
cryptodev_digest_copy: return error if allocating dstate->mac_data fails
Signed-off-by: Kurt Roeckx <kurt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
-rw-r--r-- | crypto/engine/eng_cryptodev.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/crypto/engine/eng_cryptodev.c b/crypto/engine/eng_cryptodev.c index c823eebe7c..85bc1e854e 100644 --- a/crypto/engine/eng_cryptodev.c +++ b/crypto/engine/eng_cryptodev.c @@ -901,17 +901,22 @@ static int cryptodev_digest_copy(EVP_MD_CTX *to,const EVP_MD_CTX *from) if (ioctl(dstate->d_fd, CIOCGSESSION, sess) < 0) { put_dev_crypto(dstate->d_fd); dstate->d_fd = -1; - printf("cryptodev_digest_init: Open session failed\n"); + printf("cryptodev_digest_copy: Open session failed\n"); return (0); } if (fstate->mac_len != 0) { if (fstate->mac_data != NULL) - { - dstate->mac_data = OPENSSL_malloc(fstate->mac_len); - memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len); - dstate->mac_len = fstate->mac_len; - } + { + dstate->mac_data = OPENSSL_malloc(fstate->mac_len); + if (dstate->mac_data == NULL) + { + printf("cryptodev_digest_copy: mac_data allocation failed\n"); + return (0); + } + memcpy(dstate->mac_data, fstate->mac_data, fstate->mac_len); + dstate->mac_len = fstate->mac_len; + } } return 1; |