From e8c5495b61ebde115ee133e8c85933191bd0cd61 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 2 Oct 2014 09:08:31 -0700 Subject: [PATCH] Yes, zero my secret key data. Yes I really, really mean it. --- node/Utils.cpp | 16 ++++++++++++++++ node/Utils.hpp | 14 +++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/node/Utils.cpp b/node/Utils.cpp index 80406c3f8..f0a03f2c2 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -78,6 +78,22 @@ bool Utils::redirectUnixOutputs(const char *stdoutPath,const char *stderrPath) } #endif // __UNIX_LIKE__ +static void _Utils_doBurn(char *ptr,unsigned int len) +{ + for(unsigned int i=0;i Utils::listDirectory(const char *path) { std::map r; diff --git a/node/Utils.hpp b/node/Utils.hpp index affae9a8b..defb52a93 100644 --- a/node/Utils.hpp +++ b/node/Utils.hpp @@ -101,18 +101,10 @@ public: } /** - * Securely zero memory - * - * This just uses volatile to ensure that it's never optimized out. + * Securely zero memory, avoiding compiler optimizations and such */ - static inline void burn(void *ptr,unsigned int len) - throw() - { - volatile unsigned char *p = (unsigned char *)ptr; - volatile unsigned char *e = p + len; - while (p != e) - *(p++) = (unsigned char)0; - } + static void burn(void *ptr,unsigned int len) + throw(); /** * Delete a file