summaryrefslogtreecommitdiff
path: root/libsylph/masterpassword.c
diff options
context:
space:
mode:
Diffstat (limited to 'libsylph/masterpassword.c')
-rw-r--r--libsylph/masterpassword.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libsylph/masterpassword.c b/libsylph/masterpassword.c
index 23e8f2f..77ff281 100644
--- a/libsylph/masterpassword.c
+++ b/libsylph/masterpassword.c
@@ -78,6 +78,9 @@ gchar *decrypt_with_master_password(const gchar *str) {
78 return g_strdup(str); 78 return g_strdup(str);
79 79
80 str_prefix = mpes_string_prefix(str); 80 str_prefix = mpes_string_prefix(str);
81 if (!str_prefix)
82 return g_strdup(str);
83
81 if (decrypt_data(&new_str, 84 if (decrypt_data(&new_str,
82 str + str_prefix, 85 str + str_prefix,
83 master_password, 86 master_password,
@@ -97,7 +100,7 @@ gchar *decrypt_with_master_password(const gchar *str) {
97gchar *encrypt_with_master_password(const gchar *str) { 100gchar *encrypt_with_master_password(const gchar *str) {
98 101
99#if USE_SSL 102#if USE_SSL
100 gchar *new_str; 103 gchar *new_str, *mpes1_str;
101 gint length_encrypted; 104 gint length_encrypted;
102 105
103 if ((!str) || (!master_password_active())) 106 if ((!str) || (!master_password_active()))
@@ -115,7 +118,11 @@ gchar *encrypt_with_master_password(const gchar *str) {
115 return g_strdup(str); 118 return g_strdup(str);
116 } 119 }
117 120
118 return new_str; 121 mpes1_str = g_strdup_printf("mpes1:%s", new_str);
122 OPENSSL_cleanse(new_str, strlen(new_str));
123 g_free(new_str);
124
125 return mpes1_str;
119#else 126#else
120 return g_strdup(str); 127 return g_strdup(str);
121#endif 128#endif
@@ -163,6 +170,10 @@ gint check_master_password_interactively(guint max_attempts) {
163 170
164 for (cnt = 0; cnt < max_attempts; ++cnt) { 171 for (cnt = 0; cnt < max_attempts; ++cnt) {
165 master_password = input_query_master_password(); 172 master_password = input_query_master_password();
173 if (master_password == NULL) {
174 /* input canceled or query_master_password_func not set */
175 continue;
176 }
166 if (check_password(master_password, 177 if (check_password(master_password,
167 prefs_common.master_password_hash) == RC_OK) { 178 prefs_common.master_password_hash) == RC_OK) {
168 return RC_OK; /* match */ 179 return RC_OK; /* match */