aboutsummaryrefslogtreecommitdiff
path: root/crypto/rand/randfile.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2010-01-26 18:07:26 +0000
committerDr. Stephen Henson <steve@openssl.org>2010-01-26 18:07:26 +0000
commit1bfdbd8e75a70ca2d59e868f0b8947b661f709fd (patch)
treeddc5067df43d2bd572cb5d8542060eaaf36bc7df /crypto/rand/randfile.c
parente92f9f45e87fb1ceae7cefa5d3d7fbb40dadf1f1 (diff)
downloadopenssl-1bfdbd8e75a70ca2d59e868f0b8947b661f709fd.zip
openssl-1bfdbd8e75a70ca2d59e868f0b8947b661f709fd.tar.gz
openssl-1bfdbd8e75a70ca2d59e868f0b8947b661f709fd.tar.bz2
PR: 2138
Submitted by: Kevin Regan <k.regan@f5.com> Clear stat structure if -DPURIFY is set to avoid problems on some platforms which include unitialised fields.
Diffstat (limited to 'crypto/rand/randfile.c')
-rw-r--r--crypto/rand/randfile.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index 7dc4cea..4ed40b7 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -118,6 +118,14 @@ int RAND_load_file(const char *file, long bytes)
if (file == NULL) return(0);
#ifndef OPENSSL_NO_POSIX_IO
+#ifdef PURIFY
+ /* struct stat can have padding and unused fields that may not be
+ * initialized in the call to stat(). We need to clear the entire
+ * structure before calling RAND_add() to avoid complaints from
+ * applications such as Valgrind.
+ */
+ memset(&sb, 0, sizeof(sb));
+#endif
if (stat(file,&sb) < 0) return(0);
RAND_add(&sb,sizeof(sb),0.0);
#endif