diff options
Diffstat (limited to 'src/lib/libcrypto/rand/randfile.c')
| -rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index 4a994bf73b..c3a0c12c58 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
| @@ -142,7 +142,20 @@ int RAND_write_file(const char *file) | |||
| 142 | int i,ret=0,err=0; | 142 | int i,ret=0,err=0; |
| 143 | FILE *out = NULL; | 143 | FILE *out = NULL; |
| 144 | int n; | 144 | int n; |
| 145 | 145 | struct stat sb; | |
| 146 | |||
| 147 | i=stat(file,&sb); | ||
| 148 | if (i != -1) { | ||
| 149 | if (sb.st_mode & (S_IFBLK | S_IFCHR)) { | ||
| 150 | /* this file is a device. we don't write back to it. | ||
| 151 | * we "succeed" on the assumption this is some sort | ||
| 152 | * of random device. Otherwise attempting to write to | ||
| 153 | * and chmod the device causes problems. | ||
| 154 | */ | ||
| 155 | return(1); | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 146 | #if defined(O_CREAT) && defined(O_EXCL) && !defined(WIN32) | 159 | #if defined(O_CREAT) && defined(O_EXCL) && !defined(WIN32) |
| 147 | /* For some reason Win32 can't write to files created this way */ | 160 | /* For some reason Win32 can't write to files created this way */ |
| 148 | 161 | ||
