summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2018-09-05 10:23:04 +0100
committerCarl Hetherington <cth@carlh.net>2018-09-05 10:23:04 +0100
commitde1bac3879d88d0fab638a02a78b2e29ff11386a (patch)
tree910d52d8f8f502ec52ba527368883a459fced03e
parent4de1965ecc248a7c78e3a6c539d3512ecac28ffc (diff)
Quell some valgrind errors.
-rwxr-xr-xsrc/KM_prng.cpp17
-rw-r--r--wscript2
2 files changed, 19 insertions, 0 deletions
diff --git a/src/KM_prng.cpp b/src/KM_prng.cpp
index 37a5247..28f13b7 100755
--- a/src/KM_prng.cpp
+++ b/src/KM_prng.cpp
@@ -37,6 +37,9 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <openssl/aes.h>
#include <openssl/sha.h>
#include <openssl/bn.h>
+#if HAVE_VALGRIND_MEMCHECK_H
+#include <valgrind/memcheck.h>
+#endif
using namespace Kumu;
@@ -91,6 +94,10 @@ public:
result = URandom.Read(rng_key, RNG_KEY_SIZE, &read_count);
}
+#if HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED (rng_key, RNG_KEY_SIZE);
+#endif
+
if ( KM_FAILURE(result) )
DefaultLogSink().Error("Error opening random device: %s\n", DEV_URANDOM);
@@ -114,6 +121,11 @@ public:
SHA1_Update(&SHA, key_fodder, RNG_KEY_SIZE);
SHA1_Final(sha_buf, &SHA);
+#if HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED (sha_buf, 20);
+ VALGRIND_MAKE_MEM_DEFINED (&m_Context, sizeof(m_Context));
+#endif
+
AutoMutex Lock(m_Lock);
AES_set_encrypt_key(sha_buf, RNG_KEY_SIZE_BITS, &m_Context);
ui32_t* m_ctr_buf_int = reinterpret_cast<ui32_t*> (m_ctr_buf + 12);
@@ -150,6 +162,11 @@ public:
buf[i] = rand_r(&m_cth_test_rng_state);
#endif
}
+
+#if HAVE_VALGRIND_MEMCHECK_H
+ VALGRIND_MAKE_MEM_DEFINED (buf, len);
+#endif
+
}
void reset()
diff --git a/wscript b/wscript
index 485c397..417d823 100644
--- a/wscript
+++ b/wscript
@@ -64,6 +64,8 @@ def configure(conf):
lib=['boost_filesystem%s' % boost_lib_suffix, 'boost_system%s' % boost_lib_suffix],
uselib_store='BOOST_FILESYSTEM')
+ conf.check(header_name='valgrind/memcheck.h', mandatory=False)
+
conf.recurse('src')
def build(bld):