From: Dr. Stephen Henson Date: Tue, 26 Jan 2010 18:07:41 +0000 (+0000) Subject: PR: 2138 X-Git-Tag: OpenSSL_1_0_0~83 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1cdb7854a513b29545135496a51dc02d00088f69;p=oweals%2Fopenssl.git PR: 2138 Submitted by: Kevin Regan Clear stat structure if -DPURIFY is set to avoid problems on some platforms which include unitialised fields. --- diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index 7dc4ceae8e..4ed40b7b70 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