]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Handle dict_init() and dict_lookup() failures without crashing.
authorTimo Sirainen <tss@iki.fi>
Sun, 4 May 2008 15:19:57 +0000 (18:19 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 4 May 2008 15:19:57 +0000 (18:19 +0300)
--HG--
branch : HEAD

src/plugins/expire/expire-plugin.c
src/plugins/expire/expire-tool.c

index 6d77ae19cedff2c48c4ec708d944b965fb5f8cc0..7d2f0ef12ff6ff5b1a45c951b6b2ec6c96735e2c 100644 (file)
@@ -129,7 +129,8 @@ expire_mailbox_transaction_commit(struct mailbox_transaction_context *t,
                           this is the first mail in the database */
                        ret = dict_lookup(expire.db, pool_datastack_create(),
                                          key, &value);
-                       update_dict = ret == 0 || strtoul(value, NULL, 10) == 0;
+                       update_dict = ret == 0 ||
+                               (ret > 0 && strtoul(value, NULL, 10) == 0);
                        /* may not be exactly the first message's save time
                           but a few second difference doesn't matter */
                        new_stamp = ioloop_time;
@@ -295,6 +296,8 @@ void expire_plugin_init(void)
 
                expire.env = expire_env_init(expunge_env, altmove_env);
                expire.db = dict_init(dict_uri, DICT_DATA_TYPE_UINT32, NULL);
+               if (expire.db == NULL)
+                       i_fatal("expire plugin: dict_init() failed");
                expire.username = getenv("USER");
 
                expire.next_hook_mail_storage_created =
index d17976f7ea4b5f45ca6f075821c1f897509569db..85b38fcf6ba432389c08429e72111848a98c0bb0 100644 (file)
@@ -203,6 +203,9 @@ static void expire_run(bool testrun)
        ctx.namespace_pool = pool_alloconly_create("namespaces", 1024);
        env = expire_env_init(getenv("EXPIRE"), getenv("EXPIRE_ALTMOVE"));
        dict = dict_init(getenv("EXPIRE_DICT"), DICT_DATA_TYPE_UINT32, "");
+       if (dict == NULL)
+               i_fatal("dict_init() failed");
+
        trans = dict_transaction_begin(dict);
        iter = dict_iterate_init(dict, DICT_PATH_SHARED,
                                 DICT_ITERATE_FLAG_SORT_BY_VALUE);