]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail-crypt: fs_crypt_load_keys() - Check list for NULL before dereference
authorMartti Rannanjärvi <martti.rannanjarvi@open-xchange.com>
Tue, 29 Mar 2022 03:50:50 +0000 (06:50 +0300)
committerMartti Rannanjärvi <martti.rannanjarvi@open-xchange.com>
Tue, 29 Mar 2022 03:56:39 +0000 (06:56 +0300)
NULL check was after dereference here, found by Coverity.

src/plugins/mail-crypt/fs-mail-crypt.c

index dc078f31eee1517557c4685c75759a1f5feecab8..e1d7fea68aa6b5c358181599a6a938c3dd86197f 100644 (file)
@@ -6,7 +6,6 @@ static
 int fs_crypt_load_keys(struct crypt_fs *fs, const char **error_r)
 {
        struct mailbox_list *list = mailbox_list_fs_get_list(&fs->fs);
-       struct mail_namespace *ns = mailbox_list_get_namespace(list);
        const char *error;
 
        if (fs->keys_loaded)
@@ -23,6 +22,7 @@ int fs_crypt_load_keys(struct crypt_fs *fs, const char **error_r)
                return -1;
        }
 
+       struct mail_namespace *ns = mailbox_list_get_namespace(list);
        if (null_strcmp(mail_user_plugin_getenv(ns->user, "mail_crypt_save_version"), "0") == 0)
                fs->allow_missing_keys = TRUE;
        if (mail_crypt_global_keys_load(ns->user,