summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/rand/randfile.c
diff options
context:
space:
mode:
authordjm <>2008-09-06 12:15:56 +0000
committerdjm <>2008-09-06 12:15:56 +0000
commit5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80 (patch)
treeaba68249883aa9d2361d92eef69a81d0c4961732 /src/lib/libcrypto/rand/randfile.c
parentf6198d4d0ab97685dc56be2d48715ed39fcc74b9 (diff)
downloadopenbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.tar.gz
openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.tar.bz2
openbsd-5a3c0a05c7f2c5d3c584b7c8d6aec836dd724c80.zip
import of OpenSSL 0.9.8h
Diffstat (limited to 'src/lib/libcrypto/rand/randfile.c')
-rw-r--r--src/lib/libcrypto/rand/randfile.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c
index 7183fa32e4..6c0ec9a41c 100644
--- a/src/lib/libcrypto/rand/randfile.c
+++ b/src/lib/libcrypto/rand/randfile.c
@@ -102,10 +102,8 @@ int RAND_load_file(const char *file, long bytes)
102 102
103 if (file == NULL) return(0); 103 if (file == NULL) return(0);
104 104
105 i=stat(file,&sb); 105 if (stat(file,&sb) < 0) return(0);
106 /* If the state fails, put some crap in anyway */ 106 RAND_add(&sb,sizeof(sb),0.0);
107 RAND_add(&sb,sizeof(sb),0);
108 if (i < 0) return(0);
109 if (bytes == 0) return(ret); 107 if (bytes == 0) return(ret);
110 108
111 in=fopen(file,"rb"); 109 in=fopen(file,"rb");
@@ -128,8 +126,12 @@ int RAND_load_file(const char *file, long bytes)
128 n = BUFSIZE; 126 n = BUFSIZE;
129 i=fread(buf,1,n,in); 127 i=fread(buf,1,n,in);
130 if (i <= 0) break; 128 if (i <= 0) break;
129#ifdef PURIFY
130 RAND_add(buf,i,(double)i);
131#else
131 /* even if n != i, use the full array */ 132 /* even if n != i, use the full array */
132 RAND_add(buf,n,i); 133 RAND_add(buf,n,(double)i);
134#endif
133 ret+=i; 135 ret+=i;
134 if (bytes > 0) 136 if (bytes > 0)
135 { 137 {