diff options
| author | Simeon Simeonov | 2018-04-04 13:01:37 +0200 |
|---|---|---|
| committer | Simeon Simeonov | 2018-04-04 13:01:37 +0200 |
| commit | 62c87a837463fdf09d9e7d1a605000c21f8da060 (patch) | |
| tree | 5fb0f3080a651ebe56b1d23286ae9fac57199e2a /libsylph | |
| parent | c6f80c49de727b9857d2bbd1eeaf85930612d0ce (diff) | |
Implement the wrapper function cleanse_buffer in masterpassword.c
Diffstat (limited to 'libsylph')
| -rw-r--r-- | libsylph/masterpassword.c | 12 | ||||
| -rw-r--r-- | libsylph/masterpassword.h | 1 |
2 files changed, 10 insertions, 3 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 | ||
| 41 | void unload_master_password(void) { | 41 | void 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 | |||
| 49 | void 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 @@ | |||
| 27 | extern gchar *master_password; | 27 | extern gchar *master_password; |
| 28 | void set_master_password(const char *password); | 28 | void set_master_password(const char *password); |
| 29 | gchar *get_master_password(void); | 29 | gchar *get_master_password(void); |
| 30 | void cleanse_buffer(void *buf, size_t len); | ||
| 30 | void unload_master_password(void); | 31 | void unload_master_password(void); |
| 31 | gint mpes_string_prefix(const gchar *str); | 32 | gint mpes_string_prefix(const gchar *str); |
| 32 | gboolean master_password_active(void); | 33 | gboolean master_password_active(void); |
