summaryrefslogtreecommitdiffstats
path: root/lib/libcrypto/rand/randfile.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2008-09-06 12:17:47 +0000
committerdjm <djm@openbsd.org>2008-09-06 12:17:47 +0000
commit4fcf65c5c59fcf6124cf9f1fd81aa546850f974c (patch)
tree3c0b4c46d91bcb87c8eef7a1e84711159b17f71b /lib/libcrypto/rand/randfile.c
parentimport of OpenSSL 0.9.8h (diff)
downloadwireguard-openbsd-4fcf65c5c59fcf6124cf9f1fd81aa546850f974c.tar.xz
wireguard-openbsd-4fcf65c5c59fcf6124cf9f1fd81aa546850f974c.zip
resolve conflicts
Diffstat (limited to 'lib/libcrypto/rand/randfile.c')
-rw-r--r--lib/libcrypto/rand/randfile.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/libcrypto/rand/randfile.c b/lib/libcrypto/rand/randfile.c
index d847d8ebdff..005cb38cb0c 100644
--- a/lib/libcrypto/rand/randfile.c
+++ b/lib/libcrypto/rand/randfile.c
@@ -102,10 +102,8 @@ int RAND_load_file(const char *file, long bytes)
if (file == NULL) return(0);
- i=stat(file,&sb);
- /* If the state fails, put some crap in anyway */
- RAND_add(&sb,sizeof(sb),0);
- if (i < 0) return(0);
+ if (stat(file,&sb) < 0) return(0);
+ RAND_add(&sb,sizeof(sb),0.0);
if (bytes == 0) return(ret);
in=fopen(file,"rb");
@@ -128,8 +126,12 @@ int RAND_load_file(const char *file, long bytes)
n = BUFSIZE;
i=fread(buf,1,n,in);
if (i <= 0) break;
+#ifdef PURIFY
+ RAND_add(buf,i,(double)i);
+#else
/* even if n != i, use the full array */
- RAND_add(buf,n,i);
+ RAND_add(buf,n,(double)i);
+#endif
ret+=i;
if (bytes > 0)
{