{
const struct mail_crypt_global_private_key *priv_key;
+ if (!array_is_created(&global_keys->private_keys))
+ return NULL;
+
array_foreach(&global_keys->private_keys, priv_key) {
if (strcmp(priv_key->key_id, pubkey_digest) == 0)
return priv_key->key;
test_end();
}
+static void test_empty_keyset(void)
+{
+ test_begin("test_empty_keyset");
+
+ /* this should not crash */
+ struct mail_crypt_global_keys keys;
+ memset(&keys, 0, sizeof(keys));
+ test_assert(mail_crypt_global_key_find(&keys, "423423423423") == NULL);
+
+ test_end();
+}
+
static void test_teardown(void)
{
array_free(&fs_set.plugin_envs);
void (*tests[])(void) = {
test_setup,
test_try_load_keys,
+ test_empty_keyset,
test_teardown,
NULL
};