Otherwise UAF and doublefree appears when the duplicate
is freed.
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
Reviewed-by: Paul Dale <paul.dale@oracle.com>
MergeDate: Fri Jan 23 10:37:34 2026
(Merged from https://github.com/openssl/openssl/pull/29707)
dstctx->mdctx = NULL;
dstctx->tbuf = NULL;
dstctx->propq = NULL;
+ dstctx->sig = NULL;
if (srcctx->rsa != NULL && !RSA_up_ref(srcctx->rsa))
goto err;
goto err;
}
+ if (srcctx->sig != NULL) {
+ dstctx->sig = OPENSSL_memdup(srcctx->sig, srcctx->siglen);
+ if (dstctx->sig == NULL)
+ goto err;
+ }
+
return dstctx;
err:
rsa_freectx(dstctx);