diff options
Diffstat (limited to 'lib/libcrypto/rand/randfile.c')
| -rw-r--r-- | lib/libcrypto/rand/randfile.c | 12 |
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) { |
