]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mail-crypt: Do not attempt to load empty keys
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 25 Mar 2022 12:07:40 +0000 (14:07 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Mon, 28 Mar 2022 08:47:53 +0000 (08:47 +0000)
src/plugins/mail-crypt/mail-crypt-pluginenv.c
src/plugins/mail-crypt/mail-crypt-userenv.c

index 68cf94fc6f2ef5af13d5ba411024a00155387131..101e508d61c8145dd1bd9353b8f7ee4769374532 100644 (file)
@@ -68,7 +68,8 @@ mail_crypt_load_global_private_keys(const struct fs_crypt_settings *set,
        while ((key_data = mail_crypt_plugin_getenv(set, str_c(set_key))) != NULL) {
                const char *set_pw = t_strconcat(str_c(set_key), "_password", NULL);
                const char *password = mail_crypt_plugin_getenv(set, set_pw);
-               if (mail_crypt_load_global_private_key(str_c(set_key), key_data,
+               if (*key_data != '\0' &&
+                   mail_crypt_load_global_private_key(str_c(set_key), key_data,
                                                        set_pw, password,
                                                        global_keys, error_r) < 0)
                        return -1;
@@ -89,7 +90,7 @@ int mail_crypt_global_keys_load_pluginenv(const char *set_prefix,
        int ret = 0;
 
        mail_crypt_global_keys_init(global_keys_r);
-       if (key_data != NULL) {
+       if (key_data != NULL && *key_data != '\0') {
                if (mail_crypt_load_global_public_key(set_key, key_data,
                                                      global_keys_r, error_r) < 0)
                        ret = -1;
index b152a7f01cf56fe595262284ec29e231c7f39b0e..1899d9fdba5d0a52983a74b126ae1233d8a1c2af 100644 (file)
@@ -22,7 +22,8 @@ mail_crypt_load_global_private_keys(struct mail_user *user,
        while ((key_data = mail_user_plugin_getenv(user, str_c(set_key))) != NULL) {
                const char *set_pw = t_strconcat(str_c(set_key), "_password", NULL);
                const char *password = mail_user_plugin_getenv(user, set_pw);
-               if (mail_crypt_load_global_private_key(str_c(set_key), key_data,
+               if (*key_data != '\0' &&
+                   mail_crypt_load_global_private_key(str_c(set_key), key_data,
                                                        set_pw, password,
                                                        global_keys,
                                                        error_r) < 0) {
@@ -51,7 +52,7 @@ int mail_crypt_global_keys_load(struct mail_user *user, const char *set_prefix,
        const char *key_data = mail_user_plugin_getenv(user, set_key);
 
        mail_crypt_global_keys_init(global_keys_r);
-       if (key_data != NULL) {
+       if (key_data != NULL && *key_data != '\0') {
                if (mail_crypt_load_global_public_key(set_key,
                                                      key_data,
                                                      global_keys_r,