From de403fd9274b9dfb9082415f36cd131f99c2a23f Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Sun, 25 Mar 2012 12:18:24 +0200 Subject: [PATCH] Add secret_password_clear() function * Useful for clearing passwords in memory --- docs/reference/libsecret/libsecret-sections.txt | 2 +- library/secret-password.c | 15 +++++++++++++++ library/secret-password.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/docs/reference/libsecret/libsecret-sections.txt b/docs/reference/libsecret/libsecret-sections.txt index a26fb83..d28e66f 100644 --- a/docs/reference/libsecret/libsecret-sections.txt +++ b/docs/reference/libsecret/libsecret-sections.txt @@ -109,8 +109,8 @@ secret_password_removev secret_password_remove_finish secret_password_remove_sync secret_password_removev_sync +secret_password_clear secret_password_free -
diff --git a/library/secret-password.c b/library/secret-password.c index bd5605c..6b3e22a 100644 --- a/library/secret-password.c +++ b/library/secret-password.c @@ -1125,3 +1125,18 @@ secret_password_free (gchar *password) egg_secure_strfree (password); } + +/** + * secret_password_clear: + * @password: (allow-none): password to clear + * + * Clear the memory used by a password. + */ +void +secret_password_clear (gchar *password) +{ + if (password == NULL) + return; + + egg_secure_strclear (password); +} diff --git a/library/secret-password.h b/library/secret-password.h index 8c95b6e..ca3fe44 100644 --- a/library/secret-password.h +++ b/library/secret-password.h @@ -126,6 +126,8 @@ gboolean secret_password_removev_sync (const SecretSchema *sche void secret_password_free (gchar *password); +void secret_password_clear (gchar *password); + G_END_DECLS #endif /* __SECRET_PASSWORD_H___ */