From a2f68c345a45554aeabae0382f90444e00552300 Mon Sep 17 00:00:00 2001 From: Rich Megginson Date: Fri, 18 Dec 2009 08:23:08 -0700 Subject: Make CopyObject return a new, shallow copy Due to the semantics or possibly a bug in NSSCKFWC_CopyObject(), the pem CopyObject function must return a new mdObject *. So this patch creates a new mdObject as a shallow copy of the old one. --- psession.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/psession.c b/psession.c index 82f8b41..1532fdf 100644 --- a/psession.c +++ b/psession.c @@ -178,8 +178,16 @@ pem_mdSession_CopyObject CK_RV * pError ) { + NSSCKMDObject *rvmdObject = NULL; pemInternalObject *io = (pemInternalObject *) mdOldObject->etc; + /* make a new mdObject */ + rvmdObject = nss_ZNEW(arena, NSSCKMDObject); + if ((NSSCKMDObject *) NULL == rvmdObject) { + *pError = CKR_HOST_MEMORY; + return (NSSCKMDObject *) NULL; + } + if (NULL == io->list) { io->refCount ++; } else { @@ -190,7 +198,10 @@ pem_mdSession_CopyObject item = item->next; } } - return mdOldObject; + /* struct (shallow) copy the old one */ + *rvmdObject = *mdOldObject; + + return rvmdObject; } CK_RV -- cgit