aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/src/wipeable_string.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-01-31 12:25:30 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2018-01-31 12:25:30 +0000
commitfde4489e1ddd8bc43068fcc6bddec9fb2be7f82d (patch)
tree86a527fe82c560c641e3db377eb7b747b86da733 /contrib/epee/src/wipeable_string.cpp
parentMerge pull request #3198 (diff)
downloadmonero-fde4489e1ddd8bc43068fcc6bddec9fb2be7f82d.tar.xz
wipeable_string: call memwipe directly
since the original reason for the indirect call (that memwipe was not in contrib) is now gone
Diffstat (limited to '')
-rw-r--r--contrib/epee/src/wipeable_string.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/contrib/epee/src/wipeable_string.cpp b/contrib/epee/src/wipeable_string.cpp
index 5671ed9d9..cc43b8988 100644
--- a/contrib/epee/src/wipeable_string.cpp
+++ b/contrib/epee/src/wipeable_string.cpp
@@ -27,14 +27,13 @@
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <string.h>
+#include "memwipe.h"
#include "misc_log_ex.h"
#include "wipeable_string.h"
namespace epee
{
-void *(*wipeable_string::wipefunc)(void*, size_t) = NULL;
-
wipeable_string::wipeable_string(const wipeable_string &other):
buffer(other.buffer)
{
@@ -55,12 +54,11 @@ wipeable_string::wipeable_string(const std::string &other)
wipeable_string::wipeable_string(std::string &&other)
{
- CHECK_AND_ASSERT_THROW_MES(wipefunc, "wipefunc is not set");
grow(other.size());
memcpy(buffer.data(), other.c_str(), size());
if (!other.empty())
{
- wipefunc(&other[0], other.size()); // we're kinda left with this again aren't we
+ memwipe(&other[0], other.size()); // we're kinda left with this again aren't we
other = std::string();
}
}
@@ -78,30 +76,28 @@ wipeable_string::~wipeable_string()
void wipeable_string::wipe()
{
- CHECK_AND_ASSERT_THROW_MES(wipefunc, "wipefunc is not set");
- wipefunc(buffer.data(), buffer.size() * sizeof(char));
+ memwipe(buffer.data(), buffer.size() * sizeof(char));
}
void wipeable_string::grow(size_t sz, size_t reserved)
{
- CHECK_AND_ASSERT_THROW_MES(wipefunc, "wipefunc is not set");
if (reserved < sz)
reserved = sz;
if (reserved <= buffer.capacity())
{
if (sz < buffer.size())
- wipefunc(buffer.data() + sz, buffer.size() - sz);
+ memwipe(buffer.data() + sz, buffer.size() - sz);
buffer.resize(sz);
return;
}
size_t old_sz = buffer.size();
std::unique_ptr<char[]> tmp{new char[old_sz]};
memcpy(tmp.get(), buffer.data(), old_sz * sizeof(char));
- wipefunc(buffer.data(), old_sz * sizeof(char));
+ memwipe(buffer.data(), old_sz * sizeof(char));
buffer.reserve(reserved);
buffer.resize(sz);
memcpy(buffer.data(), tmp.get(), old_sz * sizeof(char));
- wipefunc(tmp.get(), old_sz * sizeof(char));
+ memwipe(tmp.get(), old_sz * sizeof(char));
}
void wipeable_string::push_back(char c)