diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-09-05 10:23:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-09-05 10:23:04 +0100 |
| commit | de1bac3879d88d0fab638a02a78b2e29ff11386a (patch) | |
| tree | 910d52d8f8f502ec52ba527368883a459fced03e /src/KM_prng.cpp | |
| parent | 4de1965ecc248a7c78e3a6c539d3512ecac28ffc (diff) | |
Quell some valgrind errors.
Diffstat (limited to 'src/KM_prng.cpp')
| -rwxr-xr-x | src/KM_prng.cpp | 17 |
1 files changed, 17 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() |
