
From: Chenghai Huang <huangchenghai2@huawei.com> In the ctx copy function, the copy method of directly assigning a value through the pointer has a bug. In addition, the input parameter needs to be verified. Fix them. Signed-off-by: Chenghai Huang <huangchenghai2@huawei.com> Signed-off-by: JiangShui Yang <yangjiangshui@h-partners.com> --- src/uadk_prov_digest.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/uadk_prov_digest.c b/src/uadk_prov_digest.c index 2266224..8cadbcf 100644 --- a/src/uadk_prov_digest.c +++ b/src/uadk_prov_digest.c @@ -660,16 +660,15 @@ static void uadk_prov_freectx(void *dctx) static void *uadk_prov_dupctx(void *dctx) { - struct digest_priv_ctx *in; - struct digest_priv_ctx *ret; + struct digest_priv_ctx *in, *ret; + if (!dctx) return NULL; in = (struct digest_priv_ctx *)dctx; - ret = OPENSSL_zalloc(sizeof(struct digest_priv_ctx *)); - - if (ret != NULL) - *ret = *in; + ret = OPENSSL_zalloc(sizeof(struct digest_priv_ctx)); + if (ret) + memcpy(ret, in, sizeof(struct digest_priv_ctx)); return ret; } -- 2.33.0