aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2012-05-30 13:17:50 +0000
committerlloyd <[email protected]>2012-05-30 13:17:50 +0000
commita78a694779c711f9a9f6569e5de88d14527d6885 (patch)
treecaa290558884ec0dd1f16ecf3f74206ca5487d14 /src
parentf703961f20af641102db4c57e0f09e4daa7841e4 (diff)
Call clear_mem instead of memset directly
Diffstat (limited to 'src')
-rw-r--r--src/alloc/locking_allocator/locking_allocator.cpp10
-rw-r--r--src/engine/openssl/ossl_arc4.cpp3
2 files changed, 7 insertions, 6 deletions
diff --git a/src/alloc/locking_allocator/locking_allocator.cpp b/src/alloc/locking_allocator/locking_allocator.cpp
index cc7d24c8d..a5c76f563 100644
--- a/src/alloc/locking_allocator/locking_allocator.cpp
+++ b/src/alloc/locking_allocator/locking_allocator.cpp
@@ -7,8 +7,8 @@
#include <botan/locking_allocator.h>
#include <botan/internal/assert.h>
+#include <botan/mem_ops.h>
#include <algorithm>
-#include <cstring>
#include <sys/mman.h>
#include <sys/resource.h>
@@ -80,7 +80,7 @@ void* mlock_allocator::allocate(size_t n, size_t alignment)
{
const size_t offset = i->first;
m_freelist.erase(i);
- ::memset(m_pool + offset, 0, n);
+ clear_mem(m_pool + offset, n);
BOTAN_ASSERT((reinterpret_cast<size_t>(m_pool) + offset) % alignment == 0,
"Returning correctly aligned pointer");
@@ -123,7 +123,7 @@ void* mlock_allocator::allocate(size_t n, size_t alignment)
m_freelist.insert(best_fit, std::make_pair(offset, alignment_padding));
}
- ::memset(m_pool + offset + alignment_padding, 0, n);
+ clear_mem(m_pool + offset + alignment_padding, n);
BOTAN_ASSERT((reinterpret_cast<size_t>(m_pool) + offset + alignment_padding) % alignment == 0,
"Returning correctly aligned pointer");
@@ -203,7 +203,7 @@ mlock_allocator::mlock_allocator() :
if(m_pool == static_cast<byte*>(MAP_FAILED))
throw std::runtime_error("Failed to mmap pool");
- std::memset(m_pool, 0x00, m_poolsize);
+ clear_mem(m_pool, m_poolsize);
if(::mlock(m_pool, m_poolsize) != 0)
{
@@ -220,7 +220,7 @@ mlock_allocator::~mlock_allocator()
{
if(m_pool)
{
- std::memset(m_pool, 0, m_poolsize);
+ clear_mem(m_pool, m_poolsize);
::munlock(m_pool, m_poolsize);
::munmap(m_pool, m_poolsize);
m_pool = nullptr;
diff --git a/src/engine/openssl/ossl_arc4.cpp b/src/engine/openssl/ossl_arc4.cpp
index 6469d263a..cad194a59 100644
--- a/src/engine/openssl/ossl_arc4.cpp
+++ b/src/engine/openssl/ossl_arc4.cpp
@@ -19,7 +19,8 @@ namespace {
class ARC4_OpenSSL : public StreamCipher
{
public:
- void clear() { std::memset(&state, 0, sizeof(state)); }
+ void clear() { clear_mem(&state, 1); }
+
std::string name() const;
StreamCipher* clone() const { return new ARC4_OpenSSL(SKIP); }