summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2013-04-27 11:29:14 (GMT)
committerRemko Tronçon <git@el-tramo.be>2013-04-27 11:48:41 (GMT)
commit860d265a878ca444fca358f468a32df32a7f4444 (patch)
tree1d379bb1966960d87b3da53fc2ecbf3da54dca7b /Swiften/Base/SafeAllocator.h
parent5d8c328e236f57d7390d32f9ea7bd17a31e1e740 (diff)
downloadswift-860d265a878ca444fca358f468a32df32a7f4444.zip
swift-860d265a878ca444fca358f468a32df32a7f4444.tar.bz2
Zero memory more securely in SafeByteArray.
Change-Id: I0d9db512e0c525d87fddc26dc73ea95d2b54b54d
Diffstat (limited to 'Swiften/Base/SafeAllocator.h')
-rw-r--r--Swiften/Base/SafeAllocator.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/Swiften/Base/SafeAllocator.h b/Swiften/Base/SafeAllocator.h
index f59119e..b01d77d 100644
--- a/Swiften/Base/SafeAllocator.h
+++ b/Swiften/Base/SafeAllocator.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011 Remko Tronçon
+ * Copyright (c) 2011-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -10,6 +10,8 @@
#include <algorithm>
namespace Swift {
+ void secureZeroMemory(char* memory, size_t numberOfBytes);
+
template<typename T>
class SafeAllocator : public std::allocator<T> {
public:
@@ -23,8 +25,10 @@ namespace Swift {
~SafeAllocator() throw() {}
void deallocate (T* p, size_t num) {
- std::fill(reinterpret_cast<char*>(p), reinterpret_cast<char*>(p + num), 0);
+ secureZeroMemory(reinterpret_cast<char*>(p), num);
std::allocator<T>::deallocate(p, num);
}
+
+ private:
};
}