summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/rand/randfile.c
diff options
context:
space:
mode:
authorsimon <simon@FreeBSD.org>2010-03-13 19:22:41 +0000
committersimon <simon@FreeBSD.org>2010-03-13 19:22:41 +0000
commit0d816bbd980d8201a2ad23ccd05f7bde16565282 (patch)
tree909a7c21b7df72ae8c08b80b468a4dd75b3820be /crypto/openssl/crypto/rand/randfile.c
parent7fd3bd147ec574621124307eca10ead5353e34ba (diff)
parentcdb6eef1f013e22a10ab5f5829dcdc3b5e32d385 (diff)
downloadFreeBSD-src-0d816bbd980d8201a2ad23ccd05f7bde16565282.zip
FreeBSD-src-0d816bbd980d8201a2ad23ccd05f7bde16565282.tar.gz
Merge OpenSSL 0.9.8m into head.
This also "reverts" some FreeBSD local changes so we should now be back to using entirely stock OpenSSL. The local changes were simple $FreeBSD$ lines additions, which were required in the CVS days, and the patch for FreeBSD-SA-09:15.ssl which has been superseded with OpenSSL 0.9.8m's RFC5746 'TLS renegotiation extension' support. MFC after: 3 weeks
Diffstat (limited to 'crypto/openssl/crypto/rand/randfile.c')
-rw-r--r--crypto/openssl/crypto/rand/randfile.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/crypto/openssl/crypto/rand/randfile.c b/crypto/openssl/crypto/rand/randfile.c
index d108353..84276d7 100644
--- a/crypto/openssl/crypto/rand/randfile.c
+++ b/crypto/openssl/crypto/rand/randfile.c
@@ -117,6 +117,15 @@ int RAND_load_file(const char *file, long bytes)
if (file == NULL) return(0);
+#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);
if (bytes == 0) return(ret);
@@ -127,8 +136,8 @@ int RAND_load_file(const char *file, long bytes)
in=fopen(file,"rb");
#endif
if (in == NULL) goto err;
-#if defined(S_IFBLK) && defined(S_IFCHR)
- if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
+#if defined(S_ISBLK) && defined(S_ISCHR)
+ if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) {
/* this file is a device. we don't want read an infinite number
* of bytes from a random device, nor do we want to use buffered
* I/O because we will waste system entropy.
@@ -174,8 +183,8 @@ int RAND_write_file(const char *file)
i=stat(file,&sb);
if (i != -1) {
-#if defined(S_IFBLK) && defined(S_IFCHR)
- if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
+#if defined(S_ISBLK) && defined(S_ISCHR)
+ if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) {
/* this file is a device. we don't write back to it.
* we "succeed" on the assumption this is some sort
* of random device. Otherwise attempting to write to
OpenPOWER on IntegriCloud