summaryrefslogtreecommitdiff
path: root/src/KM_prng.cpp
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-08-10 22:04:02 +0200
committerCarl Hetherington <cth@carlh.net>2022-08-10 22:04:02 +0200
commit3ef6536b8b9f15a4503fa82f4b943fa566f6ac97 (patch)
tree6a575c2cc80c4d96f5475556e8dc1fb704e6f9fc /src/KM_prng.cpp
parenta276ed1c5a43a92dd2b9ca93072ce8d024329e82 (diff)
Fix mistakes in valgrind-supporting code.
Diffstat (limited to 'src/KM_prng.cpp')
-rwxr-xr-xsrc/KM_prng.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/KM_prng.cpp b/src/KM_prng.cpp
index 0a5166a..8a21299 100755
--- a/src/KM_prng.cpp
+++ b/src/KM_prng.cpp
@@ -125,7 +125,10 @@ public:
SHA1_Final(sha_buf, &SHA);
#if HAVE_VALGRIND_MEMCHECK_H
- VALGRIND_MAKE_MEM_DEFINED (sha_buf, 20);
+ /* I think AES_set_encryt_key will read 32 bytes from sha_buf
+ * even though it's only 20 bytes long, which seems dubious.
+ */
+ VALGRIND_MAKE_MEM_DEFINED (sha_buf, RNG_KEY_SIZE);
VALGRIND_MAKE_MEM_DEFINED (&m_Context, sizeof(m_Context));
#endif
@@ -201,6 +204,10 @@ Kumu::FortunaRNG::FillRandom(byte_t* buf, ui32_t len)
assert(s_RNG);
const byte_t* front_of_buffer = buf;
+#if HAVE_VALGRIND_MEMCHECK_H
+ auto const original_len = len;
+#endif
+
while ( len )
{
// 2^20 bytes max per seeding, use 2^19 to save
@@ -217,7 +224,7 @@ Kumu::FortunaRNG::FillRandom(byte_t* buf, ui32_t len)
}
#if HAVE_VALGRIND_MEMCHECK_H
- VALGRIND_MAKE_MEM_DEFINED(buf, len);
+ VALGRIND_MAKE_MEM_DEFINED(front_of_buffer, original_len);
#endif
return front_of_buffer;