summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/key.c4
-rw-r--r--src/object.c3
-rw-r--r--src/p11-tests.c1
-rw-r--r--src/p11-tests.h2
-rw-r--r--src/slot.c36
5 files changed, 45 insertions, 1 deletions
diff --git a/src/key.c b/src/key.c
index e37cdfe..fa4cd33 100644
--- a/src/key.c
+++ b/src/key.c
@@ -175,7 +175,11 @@ test_rsa_private(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
attr.ulValueLen = sizeof(buffer);
rv = (p11t_module_funcs->C_GetAttributeValue)(session, object, &attr, 1);
if(rv == CKR_ATTRIBUTE_SENSITIVE)
+ {
+ RSA_free(rsa);
return CONTINUE;
+ }
+
P11T_CHECK_RV("CKA_PRIVATE_EXPONENT", rv, CKR_OK);
rsa->d = BN_bin2bn(attr.pValue, attr.ulValueLen, NULL);
if(rsa->d == NULL)
diff --git a/src/object.c b/src/object.c
index db82fbc..c30348e 100644
--- a/src/object.c
+++ b/src/object.c
@@ -309,6 +309,9 @@ test_get_attribute_value(CK_SESSION_HANDLE session, CK_OBJECT_HANDLE object)
P11T_CHECK_BOOL("CKA_MODIFIABLE boolean value", *((CK_BBOOL*)attrs[3].pValue));
P11T_CHECK_STRING("CKA_LABEL value", attrs[4].pValue, attrs[4].ulValueLen);
+ if(attrs[4].ulValueLen)
+ free(attrs[4].pValue);
+
return CONTINUE;
}
diff --git a/src/p11-tests.c b/src/p11-tests.c
index 7950fdd..0374dc4 100644
--- a/src/p11-tests.c
+++ b/src/p11-tests.c
@@ -71,6 +71,7 @@ main(int argc, char* argv[])
p11t_module_finalize();
p11t_module_unload();
+ p11t_slot_cleanup();
p11t_config_cleanup();
return 0;
diff --git a/src/p11-tests.h b/src/p11-tests.h
index fc26380..4ab508d 100644
--- a/src/p11-tests.h
+++ b/src/p11-tests.h
@@ -196,6 +196,8 @@ extern CK_ULONG p11t_slot_count;
void p11t_slot_tests(void);
+void p11t_slot_cleanup(void);
+
CK_SLOT_ID p11t_slot_get_id(int index);
CK_SLOT_INFO_PTR p11t_slot_get_info(CK_SLOT_ID slot);
CK_TOKEN_INFO_PTR p11t_slot_get_token_info(CK_SLOT_ID slot);
diff --git a/src/slot.c b/src/slot.c
index 9658ea6..ea4bf15 100644
--- a/src/slot.c
+++ b/src/slot.c
@@ -235,6 +235,9 @@ test_slot_info(void)
if(memcmp(only, present, sizeof(CK_SLOT_ID) * n_only) != 0)
P11T_CHECK_FAIL("Present tokens don't match those in token info flags. ie: CKF_TOKEN_PRESENT");
+ free(only);
+ free(present);
+
return CONTINUE;
}
@@ -316,7 +319,6 @@ test_slot_mechanisms(void)
}
}
- /* - */
if(p11t_test_unexpected)
value = mech_count + 5;
else
@@ -389,6 +391,38 @@ p11t_slot_tests(void)
test_slot_mechanisms();
}
+void
+p11t_slot_cleanup(void)
+{
+ CK_ULONG i;
+
+ free(slot_ids);
+ slot_ids = NULL;
+
+ for(i = 0; i < p11t_slot_count; ++i)
+ {
+ free(slot_mech_type[i]);
+ free(slot_mech_info[i]);
+ }
+
+ free(slot_info);
+ slot_info = NULL;
+
+ free(slot_token_info);
+ slot_token_info = NULL;
+
+ free(slot_mech_count);
+ slot_mech_count = NULL;
+
+ free(slot_mech_type);
+ slot_mech_type = NULL;
+
+ free(slot_mech_info);
+ slot_mech_info = NULL;
+
+ p11t_slot_count = 0;
+}
+
/* ----------------------------------------------------------------------------------
* METHODS
*/