aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-01-03 03:57:33 +0000
committerlloyd <[email protected]>2009-01-03 03:57:33 +0000
commitf9027c938fc4e2b911d367094533f9acba375586 (patch)
tree0cacbf79a5caef550a4c232c5cdb61dc277a005b
parent338895f290ab5d197da596836ecc03625f9091f3 (diff)
In the Unix entropy source fast poll, clear the stat buf before
we call stat. Apparently on 32-bit Linux (or at least on Ubuntu 8.04/x86), struct stat has some padding bytes, which are not written to by the syscall, but valgrind doesn't realize that this is OK, and warns about uninitialized memory access when we read the contents of the struct. Since this data is then fed into the PRNG, the PRNG state and output becomes tainted, which makes valgrind's output rather useless.
-rw-r--r--doc/log.txt1
-rw-r--r--src/entropy/unix_procs/es_unix.cpp1
2 files changed, 2 insertions, 0 deletions
diff --git a/doc/log.txt b/doc/log.txt
index 4882cde05..32f9cae1a 100644
--- a/doc/log.txt
+++ b/doc/log.txt
@@ -1,5 +1,6 @@
* 1.8.1-pre, 2009-??-??
+ - Avoid a valgrind warning in es_unix.cpp on 32-bit Linux
- Fix memory leak in PKCS8 load_key and encrypt_key
- Relicense api.tex from CC-By-SA 2.5 to BSD
diff --git a/src/entropy/unix_procs/es_unix.cpp b/src/entropy/unix_procs/es_unix.cpp
index cf7e0a8e5..124a08da7 100644
--- a/src/entropy/unix_procs/es_unix.cpp
+++ b/src/entropy/unix_procs/es_unix.cpp
@@ -68,6 +68,7 @@ u32bit Unix_EntropySource::fast_poll(byte buf[], u32bit length)
for(u32bit j = 0; stat_targets[j]; j++)
{
struct stat statbuf;
+ clear_mem(&statbuf, 1);
::stat(stat_targets[j], &statbuf);
buf_i = xor_into_buf(buf, buf_i, length, statbuf);
}