free_session (void *data)
{
Session *sess = (Session *)data;
- if (sess)
+ if (sess) {
p11_dict_free (sess->objects);
+ p11_array_free (sess->matches);
+ }
free (sess);
}
if (sink != NULL)
(sink) (type, decoded, n_decoded, user_data);
++nfound;
+ free (decoded);
}
}
p11_hash_sha1 (checksum, input, 1000000, NULL);
CuAssertTrue (cu, memcmp (expected, checksum, P11_HASH_SHA1_LEN) == 0);
+
+ free (input);
}
const char *md5_input[] = {
#include "utf8.h"
#include <stdio.h>
+#include <stdlib.h>
#define ELEMS(x) (sizeof (x) / sizeof (x[0]))
CuAssertIntEquals (cu, fixtures[i].output_len, length);
CuAssertStrEquals (cu, fixtures[i].output, output);
+ free (output);
}
}
CuAssertIntEquals (cu, fixtures[i].output_len, length);
CuAssertStrEquals (cu, fixtures[i].output, output);
+
+ free (output);
}
}
CuAssertIntEquals (tc, fixtures[i].output_len, length);
CuAssertStrEquals (tc, fixtures[i].output, string);
+ free (string);
}
}
finish_iterating (iter, CKR_OK);
p11_array_free (iter->modules);
p11_attrs_free (iter->match_attrs);
+ free (iter->slots);
for (cb = iter->callbacks; cb != NULL; cb = next) {
next = cb->next;
(cb->destroyer) (cb->callback_data);
free (cb);
}
+
+ free (iter);
}
p11_kit_pin_unregister_callback ("/the/pin_source", callback_one,
&data);
- p11_kit_pin_ref (pin);
p11_kit_pin_unref (pin);
}
attrs = p11_attrs_buildn (NULL, NULL, 0);
rv = p11_kit_iter_load_attributes (iter, attrs, 0);
CuAssertTrue (tc, rv == CKR_OK);
+ p11_attrs_free (attrs);
}
CuAssertTrue (tc, rv == CKR_CANCEL);
CuAssert (tc, "shouldn't be reached", 0);
if (!p11_dict_set (paths, path, ""))
CuAssert (tc, "shouldn't be reached", 0);
+
+ free (path);
}
p11_dict_free (paths);
free (value);
- attr.pValue = malloc (sizeof (klass));
- return_val_if_fail (attr.pValue != NULL, P11_KIT_URI_UNEXPECTED);
-
- memcpy (attr.pValue, &klass, sizeof (klass));
+ attr.pValue = &klass;
attr.ulValueLen = sizeof (klass);
attr.type = CKA_CLASS;
p11_buffer_init (&buf, 0);
while ((rv = p11_kit_iter_next (iter)) == CKR_OK) {
- pem = p11_pem_write (ex->cert_der, ex->cert_len, "CERTIFICATE", &length);
- return_val_if_fail (pem != NULL, false);
-
if (!p11_buffer_reset (&buf, 1024))
return_val_if_reached (false);
test_check_file (tc, test.directory, "extract.pem",
SRCDIR "/files/cacert3-trusted-server-alias.pem");
+ free (test.ex.destination);
teardown (tc);
}
test_check_file (tc, test.directory, "extract.pem",
SRCDIR "/files/cacert3-trusted-alias.pem");
+ free (test.ex.destination);
teardown (tc);
}
test_check_file (tc, test.directory, "extract.pem",
SRCDIR "/files/cacert3-trusted-keyid.pem");
+ free (test.ex.destination);
teardown (tc);
}
test_check_file (tc, test.directory, "extract.pem",
SRCDIR "/files/cacert3-not-trusted.pem");
+ free (test.ex.destination);
teardown (tc);
}
test_check_file (tc, test.directory, "extract.pem",
SRCDIR "/files/cacert3-distrust-all.pem");
+ free (test.ex.destination);
teardown (tc);
}
test_check_file (tc, test.directory, "extract.pem",
SRCDIR "/files/cacert3-trusted-multiple.pem");
+ free (test.ex.destination);
teardown (tc);
}
test_check_data (tc, test.directory, "extract.pem", "", 0);
+ free (test.ex.destination);
teardown (tc);
}
test_check_file (tc, test.directory, "extract.pem", SRCDIR "/files/cacert3.pem");
+ free (test.ex.destination);
teardown (tc);
}
test_check_file (tc, test.directory, "extract.pem", SRCDIR "/files/cacert3-twice.pem");
+ free (test.ex.destination);
teardown (tc);
}
p11_kit_iter_add_filter (test.iter, certificate_filter, 1);
p11_kit_iter_begin_with (test.iter, &test.module, 0, 0);
- if (asprintf (&test.ex.destination, "%s/%s", test.directory, "extract.cer") < 0)
- assert_not_reached ();
-
if (asprintf (&test.ex.destination, "%s/%s", test.directory, "extract.pem") < 0)
assert_not_reached ();
test_check_data (tc, test.directory, "extract.pem", "", 0);
+ free (test.ex.destination);
teardown (tc);
}
CuAssertTrue (tc, fd != -1);
res = close (fd);
CuAssertTrue (tc, res >= 0);
+
+ free (filename);
}
static void
test_check_file (tc, test.directory, "extract.cer", SRCDIR "/files/cacert3.der");
+ free (test.ex.destination);
teardown (tc);
}
test_check_file (tc, test.directory, "extract.cer", SRCDIR "/files/cacert3.der");
+ free (test.ex.destination);
teardown (tc);
}
p11_message_loud ();
+ free (test.ex.destination);
teardown (tc);
}
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
{
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);
rv = index_build (index, &obj->attrs, attrs);
if (rv != CKR_OK) {
p11_attrs_free (attrs);
+ free (obj);
return rv;
}
CK_SLOT_ID slot;
const char *path;
const char *label;
+ char *alloc;
char *remaining;
char *base;
char *pos;
p11_debug ("using paths: %s", paths);
- remaining = strdup (paths);
+ alloc = remaining = strdup (paths);
return_val_if_fail (remaining != NULL, false);
while (remaining) {
}
}
- free (remaining);
+ free (alloc);
return true;
}
p11_session *session = data;
p11_session_set_operation (session, NULL, NULL);
+ p11_builder_free (session->builder);
p11_index_free (session->index);
free (session);
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
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 ();
};
CK_ATTRIBUTE *attrs;
+ CK_ATTRIBUTE *merge;
CK_RV rv;
setup (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 ();
for (i = 0; i < NUM; i++)
CuAssertIntEquals (cu, expected[i], snapshot[i]);
+ free (snapshot);
teardown (cu);
}
for (i = 0; i < NUM * 2; i++)
CuAssertIntEquals (cu, expected[i / 2], snapshot[i]);
+ free (snapshot);
teardown (cu);
}
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);
CuAssertTrue (cu, rv == CKR_OK);
p11_index_finish (index);
CuAssertIntEquals (cu, 1, on_change_called);
+
+ p11_index_free (index);
}
int
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