From 66a40a37cda74dfc59690cd8897ef21403cc9817 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 20 Apr 2016 13:31:34 +0100 Subject: [PATCH] prompt: zero password memory after running the command to be slightly more secure --- src/commands.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/commands.cc b/src/commands.cc index 3ddfcc3a5..119aa0fe7 100644 --- a/src/commands.cc +++ b/src/commands.cc @@ -1585,7 +1585,11 @@ const CommandDesc prompt_cmd = { CommandManager::instance().execute(command, context, shell_context); if (password) + { + const String& str = RegisterManager::instance()[reg].values(context)[0]; + memset(const_cast(str).data(), 0, (int)str.length()); RegisterManager::instance()[reg] = ConstArrayView(""); + } }); } };