Forget entered master password before trying to change it.
authorAndrej Kacian <ticho@claws-mail.org>
Sun, 7 Feb 2016 18:51:20 +0000 (19:51 +0100)
committerAndrej Kacian <ticho@claws-mail.org>
Sun, 7 Feb 2016 18:51:20 +0000 (19:51 +0100)
This makes sure the user always has to input current master
password before he is allowed to change it.

src/password.c
src/password.h

index 180f6f4ecb7eb657301a05254e04f08e8c513fbc..69d8c01ea5f2d480193dfaa3af82336945fd801c 100644 (file)
@@ -117,6 +117,17 @@ const gboolean master_password_is_correct(const gchar *input)
        return FALSE;
 }
 
+void master_password_forget()
+{
+       /* If master password is currently in memory (entered by user),
+        * get rid of it. User will have to enter the new one again. */
+       if (_master_password != NULL) {
+               memset(_master_password, 0, strlen(_master_password));
+               g_free(_master_password);
+       }
+       _master_password = NULL;
+}
+
 void master_password_change(const gchar *newp)
 {
        gchar *pwd, *newpwd;
@@ -124,6 +135,10 @@ void master_password_change(const gchar *newp)
        GList *cur;
        PrefsAccount *acc;
 
+       /* Make sure the user has to enter the master password before
+        * being able to change it. */
+       master_password_forget();
+
        oldp = master_password();
        g_return_if_fail(oldp != NULL);
 
@@ -190,13 +205,7 @@ void master_password_change(const gchar *newp)
                }
        }
 
-       /* If master password is currently in memory (entered by user),
-        * get rid of it. User will have to enter the new one again. */
-       if (_master_password != NULL) {
-               memset(_master_password, 0, strlen(_master_password));
-               g_free(_master_password);
-       }
-       _master_password = NULL;
+       master_password_forget();
 }
 #endif
 
index df18e34ec59b27b1ff1e0137f2d81087ef50c13d..e0126ff0f1b2954b07c7499f24d5f216a4b1d16d 100644 (file)
@@ -29,6 +29,7 @@
 #ifndef PASSWORD_CRYPTO_OLD
 const gboolean master_password_is_set();
 const gboolean master_password_is_correct(const gchar *input);
+void master_password_forget();
 void master_password_change(const gchar *newp);
 #endif