changeset 21242:695b138a2f33

mail-crypt: Fail if key is not found and save_version less than 2 Fail if save version is set to 0 or 1, instead of trying to use undefined value for public key.
author Aki Tuomi <aki.tuomi@dovecot.fi>
date Mon, 28 Nov 2016 14:45:01 +0200
parents 18093e101774
children 4bbb78b14970
files src/plugins/mail-crypt/mail-crypt-plugin.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/mail-crypt/mail-crypt-plugin.c	Mon Nov 28 13:36:56 2016 +0200
+++ b/src/plugins/mail-crypt/mail-crypt-plugin.c	Mon Nov 28 14:45:01 2016 +0200
@@ -296,8 +296,17 @@
 				return ret;
 			}
 
-			if (muser->save_version > 1 &&
-			    mail_crypt_box_generate_keypair(box, &pair, NULL,
+			if (muser->save_version < 2) {
+				mail_storage_set_error(box->storage,
+                                        MAIL_ERROR_PARAMS,
+                                        t_strdup_printf("generate_keypair(%s) failed: "
+                                                        "unsupported save_version=%d",
+                                                        mailbox_get_vname(box),
+                                                        muser->save_version));
+                                return -1;
+			}
+
+			if (mail_crypt_box_generate_keypair(box, &pair, NULL,
 							    &pubid, &error) < 0) {
 				mail_storage_set_error(box->storage,
 					MAIL_ERROR_PARAMS,