summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimeon Simeonov2018-04-04 13:01:37 +0200
committerSimeon Simeonov2018-04-04 13:01:37 +0200
commit62c87a837463fdf09d9e7d1a605000c21f8da060 (patch)
tree5fb0f3080a651ebe56b1d23286ae9fac57199e2a
parentc6f80c49de727b9857d2bbd1eeaf85930612d0ce (diff)
Implement the wrapper function cleanse_buffer in masterpassword.c
-rw-r--r--libsylph/masterpassword.c12
-rw-r--r--libsylph/masterpassword.h1
-rw-r--r--src/inputdialog.c6
3 files changed, 14 insertions, 5 deletions
diff --git a/libsylph/masterpassword.c b/libsylph/masterpassword.c
index b86f06b..2da6969 100644
--- a/libsylph/masterpassword.c
+++ b/libsylph/masterpassword.c
@@ -38,11 +38,17 @@ gchar *get_master_password(void) {
38 return master_password; 38 return master_password;
39} 39}
40 40
41void unload_master_password(void) { 41void cleanse_buffer(void *buf, size_t len) {
42
43#if USE_SSL 42#if USE_SSL
44 OPENSSL_cleanse(master_password, strlen(master_password)); 43 OPENSSL_cleanse(buf, len);
44#else
45 memset(buf, 0, len); /* better than nothing */
45#endif 46#endif
47}
48
49void unload_master_password(void) {
50
51 cleanse_buffer(master_password, strlen(master_password));
46 g_free(master_password); 52 g_free(master_password);
47 master_password = NULL; 53 master_password = NULL;
48 54
diff --git a/libsylph/masterpassword.h b/libsylph/masterpassword.h
index 91f3793..cc32358 100644
--- a/libsylph/masterpassword.h
+++ b/libsylph/masterpassword.h
@@ -27,6 +27,7 @@
27extern gchar *master_password; 27extern gchar *master_password;
28void set_master_password(const char *password); 28void set_master_password(const char *password);
29gchar *get_master_password(void); 29gchar *get_master_password(void);
30void cleanse_buffer(void *buf, size_t len);
30void unload_master_password(void); 31void unload_master_password(void);
31gint mpes_string_prefix(const gchar *str); 32gint mpes_string_prefix(const gchar *str);
32gboolean master_password_active(void); 33gboolean master_password_active(void);
diff --git a/src/inputdialog.c b/src/inputdialog.c
index 340e488..2510bbb 100644
--- a/src/inputdialog.c
+++ b/src/inputdialog.c
@@ -44,6 +44,7 @@
44#include "filesel.h" 44#include "filesel.h"
45#include "prefs_common.h" 45#include "prefs_common.h"
46#include "gtkutils.h" 46#include "gtkutils.h"
47#include "masterpassword.h"
47#include "utils.h" 48#include "utils.h"
48 49
49#define DIALOG_WIDTH 420 50#define DIALOG_WIDTH 420
@@ -182,11 +183,12 @@ gchar *input_dialog_set_new_password(guint max_attempts)
182 NULL); 183 NULL);
183 184
184 if (pass1 != NULL && pass2 != NULL && strcmp(pass1, pass2) == 0) { 185 if (pass1 != NULL && pass2 != NULL && strcmp(pass1, pass2) == 0) {
185 /* TODO: clear before free? */ 186 cleanse_buffer(pass2, strlen(pass2));
186 g_free(pass2); 187 g_free(pass2);
187 break; 188 break;
188 } 189 }
189 /* TODO: clear before free? */ 190 cleanse_buffer(pass1, strlen(pass1));
191 cleanse_buffer(pass2, strlen(pass2));
190 g_free(pass2); 192 g_free(pass2);
191 g_free(pass1); 193 g_free(pass1);
192 pass1 = NULL; 194 pass1 = NULL;