aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/epee/include/misc_os_dependent.h4
-rw-r--r--contrib/epee/src/wipeable_string.cpp9
2 files changed, 8 insertions, 5 deletions
diff --git a/contrib/epee/include/misc_os_dependent.h b/contrib/epee/include/misc_os_dependent.h
index 99690b301..ffe575501 100644
--- a/contrib/epee/include/misc_os_dependent.h
+++ b/contrib/epee/include/misc_os_dependent.h
@@ -75,13 +75,13 @@ namespace misc_utils
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
- return (mts.tv_sec * 1000000000) + (mts.tv_nsec);
+ return ((uint64_t)mts.tv_sec * 1000000000) + (mts.tv_nsec);
#else
struct timespec ts;
if(clock_gettime(CLOCK_MONOTONIC, &ts) != 0) {
return 0;
}
- return (ts.tv_sec * 1000000000) + (ts.tv_nsec);
+ return ((uint64_t)ts.tv_sec * 1000000000) + (ts.tv_nsec);
#endif
}
diff --git a/contrib/epee/src/wipeable_string.cpp b/contrib/epee/src/wipeable_string.cpp
index cc43b8988..6ed4ee8a2 100644
--- a/contrib/epee/src/wipeable_string.cpp
+++ b/contrib/epee/src/wipeable_string.cpp
@@ -76,7 +76,8 @@ wipeable_string::~wipeable_string()
void wipeable_string::wipe()
{
- memwipe(buffer.data(), buffer.size() * sizeof(char));
+ if (!buffer.empty())
+ memwipe(buffer.data(), buffer.size() * sizeof(char));
}
void wipeable_string::grow(size_t sz, size_t reserved)
@@ -93,11 +94,13 @@ void wipeable_string::grow(size_t sz, size_t reserved)
size_t old_sz = buffer.size();
std::unique_ptr<char[]> tmp{new char[old_sz]};
memcpy(tmp.get(), buffer.data(), old_sz * sizeof(char));
- memwipe(buffer.data(), old_sz * sizeof(char));
+ if (old_sz > 0)
+ memwipe(buffer.data(), old_sz * sizeof(char));
buffer.reserve(reserved);
buffer.resize(sz);
memcpy(buffer.data(), tmp.get(), old_sz * sizeof(char));
- memwipe(tmp.get(), old_sz * sizeof(char));
+ if (old_sz > 0)
+ memwipe(tmp.get(), old_sz * sizeof(char));
}
void wipeable_string::push_back(char c)