diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index d847d8ebdf..005cb38cb0 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 | { |
