From 1602b008531ba6e0c704588cb2643daef26b71d9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 14 Oct 2015 22:40:23 +0200 Subject: tree-wide: whenever we deal with passwords, erase them from memory after use A bit snake-oilish, but can't hurt. --- src/firstboot/firstboot.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/firstboot/firstboot.c') diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c index 1562ccf0d7..da247fbef8 100644 --- a/src/firstboot/firstboot.c +++ b/src/firstboot/firstboot.c @@ -51,15 +51,6 @@ static bool arg_copy_locale = false; static bool arg_copy_timezone = false; static bool arg_copy_root_password = false; -static void clear_string(char *x) { - - if (!x) - return; - - /* A delicious drop of snake-oil! */ - memset(x, 'x', strlen(x)); -} - static bool press_any_key(void) { char k = 0; bool need_nl = true; @@ -477,18 +468,18 @@ static int prompt_root_password(void) { r = ask_password_tty(msg2, NULL, 0, 0, NULL, &b); if (r < 0) { - clear_string(a); + string_erase(a); return log_error_errno(r, "Failed to query root password: %m"); } if (!streq(a, b)) { log_error("Entered passwords did not match, please try again."); - clear_string(a); - clear_string(b); + string_erase(a); + string_erase(b); continue; } - clear_string(b); + string_erase(b); arg_root_password = a; a = NULL; break; @@ -881,7 +872,7 @@ finish: free(arg_locale_messages); free(arg_timezone); free(arg_hostname); - clear_string(arg_root_password); + string_erase(arg_root_password); free(arg_root_password); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; -- cgit v1.2.3-54-g00ecf