From 62c87a837463fdf09d9e7d1a605000c21f8da060 Mon Sep 17 00:00:00 2001 From: Simeon Simeonov Date: Wed, 4 Apr 2018 13:01:37 +0200 Subject: Implement the wrapper function cleanse_buffer in masterpassword.c --- libsylph/masterpassword.c | 12 +++++++++--- libsylph/masterpassword.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'libsylph') 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) { return master_password; } -void unload_master_password(void) { - +void cleanse_buffer(void *buf, size_t len) { #if USE_SSL - OPENSSL_cleanse(master_password, strlen(master_password)); + OPENSSL_cleanse(buf, len); +#else + memset(buf, 0, len); /* better than nothing */ #endif +} + +void unload_master_password(void) { + + cleanse_buffer(master_password, strlen(master_password)); g_free(master_password); master_password = NULL; 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 @@ extern gchar *master_password; void set_master_password(const char *password); gchar *get_master_password(void); +void cleanse_buffer(void *buf, size_t len); void unload_master_password(void); gint mpes_string_prefix(const gchar *str); gboolean master_password_active(void); -- cgit v1.3