summaryrefslogtreecommitdiff
path: root/trust
diff options
context:
space:
mode:
Diffstat (limited to 'trust')
-rw-r--r--trust/builder.c2
-rw-r--r--trust/index.c7
-rw-r--r--trust/module.c5
-rw-r--r--trust/session.c1
-rw-r--r--trust/tests/test-builder.c51
-rw-r--r--trust/tests/test-index.c5
-rw-r--r--trust/tests/test-module.c2
7 files changed, 58 insertions, 15 deletions
diff --git a/trust/builder.c b/trust/builder.c
index 93c5f3e..53201ed 100644
--- a/trust/builder.c
+++ b/trust/builder.c
@@ -1159,6 +1159,8 @@ replace_nss_trust_object (p11_builder *builder,
rv = p11_index_replace_all (index, match, CKA_INVALID, array);
return_if_fail (rv == CKR_OK);
p11_array_free (array);
+
+ p11_attrs_free (match);
}
static void
diff --git a/trust/index.c b/trust/index.c
index 1275cd9..c8632cc 100644
--- a/trust/index.c
+++ b/trust/index.c
@@ -293,10 +293,10 @@ index_notify (p11_index *index,
{
index_object *obj;
- if (!index->notify || index->notifying)
- return;
+ if (!index->notify || index->notifying) {
+ p11_attrs_free (removed);
- if (!index->changes) {
+ } else if (!index->changes) {
call_notify (index, handle, removed);
p11_attrs_free (removed);
@@ -373,6 +373,7 @@ p11_index_take (p11_index *index,
rv = index_build (index, &obj->attrs, attrs);
if (rv != CKR_OK) {
p11_attrs_free (attrs);
+ free (obj);
return rv;
}
diff --git a/trust/module.c b/trust/module.c
index a819303..6be2847 100644
--- a/trust/module.c
+++ b/trust/module.c
@@ -188,6 +188,7 @@ create_tokens_inlock (p11_array *tokens,
CK_SLOT_ID slot;
const char *path;
const char *label;
+ char *alloc;
char *remaining;
char *base;
char *pos;
@@ -195,7 +196,7 @@ create_tokens_inlock (p11_array *tokens,
p11_debug ("using paths: %s", paths);
- remaining = strdup (paths);
+ alloc = remaining = strdup (paths);
return_val_if_fail (remaining != NULL, false);
while (remaining) {
@@ -240,7 +241,7 @@ create_tokens_inlock (p11_array *tokens,
}
}
- free (remaining);
+ free (alloc);
return true;
}
diff --git a/trust/session.c b/trust/session.c
index 19434ff..2a8c9f9 100644
--- a/trust/session.c
+++ b/trust/session.c
@@ -77,6 +77,7 @@ p11_session_free (void *data)
p11_session *session = data;
p11_session_set_operation (session, NULL, NULL);
+ p11_builder_free (session->builder);
p11_index_free (session->index);
free (session);
diff --git a/trust/tests/test-builder.c b/trust/tests/test-builder.c
index be5390e..3212bac 100644
--- a/trust/tests/test-builder.c
+++ b/trust/tests/test-builder.c
@@ -429,6 +429,7 @@ test_build_certificate_no_type (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -436,8 +437,10 @@ test_build_certificate_no_type (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -456,6 +459,7 @@ test_build_certificate_bad_type (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -463,8 +467,10 @@ test_build_certificate_bad_type (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -524,6 +530,7 @@ test_create_not_settable (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -531,8 +538,10 @@ test_create_not_settable (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -587,6 +596,7 @@ test_create_unsupported (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -594,8 +604,10 @@ test_create_unsupported (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -613,6 +625,7 @@ test_create_generated (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -620,8 +633,10 @@ test_create_generated (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -639,6 +654,7 @@ test_create_bad_attribute (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -646,8 +662,10 @@ test_create_bad_attribute (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -663,6 +681,7 @@ test_create_missing_attribute (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -670,8 +689,10 @@ test_create_missing_attribute (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -687,6 +708,7 @@ test_create_no_class (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -694,8 +716,10 @@ test_create_no_class (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_TEMPLATE_INCOMPLETE, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -712,6 +736,7 @@ test_create_token_mismatch (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -719,8 +744,10 @@ test_create_token_mismatch (CuTest *cu)
p11_message_quiet ();
attrs = NULL;
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (input));
+ merge = p11_attrs_dup (input);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_TEMPLATE_INCONSISTENT, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -800,6 +827,7 @@ test_modify_read_only (CuTest *cu)
merge = p11_attrs_dup (modify);
rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
@@ -869,6 +897,7 @@ test_modify_not_modifiable (CuTest *cu)
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (cu);
@@ -879,8 +908,10 @@ test_modify_not_modifiable (CuTest *cu)
p11_message_quiet ();
- rv = p11_builder_build (test.builder, test.index, &attrs, p11_attrs_dup (modify));
+ merge = p11_attrs_dup (modify);
+ rv = p11_builder_build (test.builder, test.index, &attrs, merge);
CuAssertIntEquals (cu, CKR_ATTRIBUTE_READ_ONLY, rv);
+ p11_attrs_free (merge);
p11_message_loud ();
diff --git a/trust/tests/test-index.c b/trust/tests/test-index.c
index d58a510..14f5a8a 100644
--- a/trust/tests/test-index.c
+++ b/trust/tests/test-index.c
@@ -192,6 +192,7 @@ test_snapshot (CuTest *cu)
for (i = 0; i < NUM; i++)
CuAssertIntEquals (cu, expected[i], snapshot[i]);
+ free (snapshot);
teardown (cu);
}
@@ -229,6 +230,7 @@ test_snapshot_base (CuTest *cu)
for (i = 0; i < NUM * 2; i++)
CuAssertIntEquals (cu, expected[i / 2], snapshot[i]);
+ free (snapshot);
teardown (cu);
}
@@ -665,6 +667,7 @@ test_replace_all (CuTest *tc)
CuAssertTrue (tc, rv == CKR_OK);
CuAssertIntEquals (tc, 0, array->num);
+ p11_array_free (array);
/* eins should have replaced one */
check = p11_index_find (test.index, eins, -1);
@@ -1021,6 +1024,8 @@ test_change_nested (CuTest *cu)
CuAssertTrue (cu, rv == CKR_OK);
p11_index_finish (index);
CuAssertIntEquals (cu, 1, on_change_called);
+
+ p11_index_free (index);
}
int
diff --git a/trust/tests/test-module.c b/trust/tests/test-module.c
index 1d97f9b..1033b05 100644
--- a/trust/tests/test-module.c
+++ b/trust/tests/test-module.c
@@ -431,6 +431,8 @@ check_has_trust_object (CuTest *cu,
check_trust_object_equiv (cu, sessions[0], objects[0], cert);
check_trust_object_hashes (cu, sessions[0], objects[0], cert);
+
+ p11_attrs_free (match);
}
static void