提交 349e6b2b 编写于 作者: J Jonas Maebe 提交者: Kurt Roeckx

cryptodev_digest_update: don't leak original state->mac_data if realloc fails

Signed-off-by: NKurt Roeckx <kurt@openssl.org>
Reviewed-by: NRich Salz <rsalz@openssl.org>
上级 36f7ed50
...@@ -765,6 +765,7 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data, ...@@ -765,6 +765,7 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
struct crypt_op cryp; struct crypt_op cryp;
struct dev_crypto_state *state = ctx->md_data; struct dev_crypto_state *state = ctx->md_data;
struct session_op *sess = &state->d_sess; struct session_op *sess = &state->d_sess;
char *new_mac_data;
if (!data || state->d_fd < 0) { if (!data || state->d_fd < 0) {
printf("cryptodev_digest_update: illegal inputs \n"); printf("cryptodev_digest_update: illegal inputs \n");
...@@ -777,12 +778,13 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data, ...@@ -777,12 +778,13 @@ static int cryptodev_digest_update(EVP_MD_CTX *ctx, const void *data,
if (!(ctx->flags & EVP_MD_CTX_FLAG_ONESHOT)) { if (!(ctx->flags & EVP_MD_CTX_FLAG_ONESHOT)) {
/* if application doesn't support one buffer */ /* if application doesn't support one buffer */
state->mac_data = OPENSSL_realloc(state->mac_data, state->mac_len + count); new_mac_data = OPENSSL_realloc(state->mac_data, state->mac_len + count);
if (!state->mac_data) { if (!new_mac_data) {
printf("cryptodev_digest_update: realloc failed\n"); printf("cryptodev_digest_update: realloc failed\n");
return (0); return (0);
} }
state->mac_data = new_mac_data;
memcpy(state->mac_data + state->mac_len, data, count); memcpy(state->mac_data + state->mac_len, data, count);
state->mac_len += count; state->mac_len += count;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册