diff options
Diffstat (limited to 'src/lib/libcrypto/rand/randfile.c')
-rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index 6c0ec9a41c..d847d8ebdf 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
@@ -102,8 +102,10 @@ 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 | if (stat(file,&sb) < 0) return(0); | 105 | i=stat(file,&sb); |
106 | RAND_add(&sb,sizeof(sb),0.0); | 106 | /* If the state fails, put some crap in anyway */ |
107 | RAND_add(&sb,sizeof(sb),0); | ||
108 | if (i < 0) return(0); | ||
107 | if (bytes == 0) return(ret); | 109 | if (bytes == 0) return(ret); |
108 | 110 | ||
109 | in=fopen(file,"rb"); | 111 | in=fopen(file,"rb"); |
@@ -126,12 +128,8 @@ int RAND_load_file(const char *file, long bytes) | |||
126 | n = BUFSIZE; | 128 | n = BUFSIZE; |
127 | i=fread(buf,1,n,in); | 129 | i=fread(buf,1,n,in); |
128 | if (i <= 0) break; | 130 | if (i <= 0) break; |
129 | #ifdef PURIFY | ||
130 | RAND_add(buf,i,(double)i); | ||
131 | #else | ||
132 | /* even if n != i, use the full array */ | 131 | /* even if n != i, use the full array */ |
133 | RAND_add(buf,n,(double)i); | 132 | RAND_add(buf,n,i); |
134 | #endif | ||
135 | ret+=i; | 133 | ret+=i; |
136 | if (bytes > 0) | 134 | if (bytes > 0) |
137 | { | 135 | { |
@@ -235,7 +233,7 @@ const char *RAND_file_name(char *buf, size_t size) | |||
235 | struct stat sb; | 233 | struct stat sb; |
236 | #endif | 234 | #endif |
237 | 235 | ||
238 | if (OPENSSL_issetugid() == 0) | 236 | if (issetugid() == 0) |
239 | s=getenv("RANDFILE"); | 237 | s=getenv("RANDFILE"); |
240 | if (s != NULL && *s && strlen(s) + 1 < size) | 238 | if (s != NULL && *s && strlen(s) + 1 < size) |
241 | { | 239 | { |
@@ -244,7 +242,7 @@ const char *RAND_file_name(char *buf, size_t size) | |||
244 | } | 242 | } |
245 | else | 243 | else |
246 | { | 244 | { |
247 | if (OPENSSL_issetugid() == 0) | 245 | if (issetugid() == 0) |
248 | s=getenv("HOME"); | 246 | s=getenv("HOME"); |
249 | #ifdef DEFAULT_HOME | 247 | #ifdef DEFAULT_HOME |
250 | if (s == NULL) | 248 | if (s == NULL) |