summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/hx509/ks_p11.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/hx509/ks_p11.c')
-rw-r--r--source4/heimdal/lib/hx509/ks_p11.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/source4/heimdal/lib/hx509/ks_p11.c b/source4/heimdal/lib/hx509/ks_p11.c
index 0d7c312c72..bf46e6604e 100644
--- a/source4/heimdal/lib/hx509/ks_p11.c
+++ b/source4/heimdal/lib/hx509/ks_p11.c
@@ -32,7 +32,7 @@
*/
#include "hx_locl.h"
-RCSID("$Id: ks_p11.c 22071 2007-11-14 20:04:50Z lha $");
+RCSID("$Id: ks_p11.c 22899 2008-04-07 18:52:36Z lha $");
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
@@ -65,7 +65,7 @@ struct p11_module {
void *dl_handle;
CK_FUNCTION_LIST_PTR funcs;
CK_ULONG num_slots;
- unsigned int refcount;
+ unsigned int ref;
struct p11_slot *slot;
};
@@ -309,7 +309,8 @@ p11_init_slot(hx509_context context,
CK_SESSION_HANDLE session;
CK_SLOT_INFO slot_info;
CK_TOKEN_INFO token_info;
- int ret, i;
+ size_t i;
+ int ret;
slot->certs = NULL;
slot->id = id;
@@ -640,9 +641,11 @@ collect_private_key(hx509_context context,
p11rsa->slot = slot;
p11rsa->private_key = object;
- p->refcount++;
- if (p->refcount == 0)
- _hx509_abort("pkcs11 refcount to high");
+ if (p->ref == 0)
+ _hx509_abort("pkcs11 ref == 0 on alloc");
+ p->ref++;
+ if (p->ref == UINT_MAX)
+ _hx509_abort("pkcs11 ref == UINT_MAX on alloc");
RSA_set_method(rsa, &p11_rsa_pkcs1_method);
ret = RSA_set_app_data(rsa, p11rsa);
@@ -695,9 +698,11 @@ collect_cert(hx509_context context,
if (ret)
return ret;
- p->refcount++;
- if (p->refcount == 0)
- _hx509_abort("pkcs11 refcount to high");
+ if (p->ref == 0)
+ _hx509_abort("pkcs11 ref == 0 on alloc");
+ p->ref++;
+ if (p->ref == UINT_MAX)
+ _hx509_abort("pkcs11 ref to high");
_hx509_cert_set_release(cert, p11_cert_release, p);
@@ -808,7 +813,7 @@ p11_init(hx509_context context,
return ENOMEM;
}
- p->refcount = 1;
+ p->ref = 1;
str = strchr(list, ',');
if (str)
@@ -934,9 +939,9 @@ p11_release_module(struct p11_module *p)
{
int i;
- if (p->refcount == 0)
- _hx509_abort("pkcs11 refcount to low");
- if (--p->refcount > 0)
+ if (p->ref == 0)
+ _hx509_abort("pkcs11 ref to low");
+ if (--p->ref > 0)
return;
for (i = 0; i < p->num_slots; i++) {