talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit fb564a461e8d8f343ed7e4eb1f8bcaa1cd1f48e3
parent b7477fbe534b8d1712b27a737d55b82c2a294b97
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sun,  7 Feb 2016 19:51:20 +0100

Forget entered master password before trying to change it.

This makes sure the user always has to input current master
password before he is allowed to change it.

Diffstat:
Msrc/password.c | 23++++++++++++++++-------
Msrc/password.h | 1+
2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/password.c b/src/password.c @@ -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 diff --git a/src/password.h b/src/password.h @@ -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