diff options
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 31 | 
1 files changed, 24 insertions, 7 deletions
| diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index c3a0c12c58..53a75667f4 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
| @@ -218,6 +218,7 @@ const char *RAND_file_name(char *buf, int size) | |||
| 218 | { | 218 | { | 
| 219 | char *s; | 219 | char *s; | 
| 220 | char *ret=NULL; | 220 | char *ret=NULL; | 
| 221 | struct stat sb; | ||
| 221 | 222 | ||
| 222 | s=getenv("RANDFILE"); | 223 | s=getenv("RANDFILE"); | 
| 223 | if (s != NULL) | 224 | if (s != NULL) | 
| @@ -229,15 +230,31 @@ const char *RAND_file_name(char *buf, int size) | |||
| 229 | else | 230 | else | 
| 230 | { | 231 | { | 
| 231 | s=getenv("HOME"); | 232 | s=getenv("HOME"); | 
| 232 | if (s == NULL) return(RFILE); | 233 | if (s == NULL) | 
| 233 | if (((int)(strlen(s)+strlen(RFILE)+2)) > size) | 234 | ret = RFILE; | 
| 234 | return(RFILE); | 235 | if (((int)(strlen(s)+strlen(RFILE)+2)) > size) | 
| 235 | strcpy(buf,s); | 236 | ret=RFILE; | 
| 237 | else | ||
| 238 | { | ||
| 239 | strlcpy(buf,s,size); | ||
| 236 | #ifndef VMS | 240 | #ifndef VMS | 
| 237 | strcat(buf,"/"); | 241 | strcat(buf,"/"); | 
| 238 | #endif | 242 | #endif | 
| 239 | strcat(buf,RFILE); | 243 | strlcat(buf,RFILE,size); | 
| 240 | ret=buf; | 244 | ret=buf; | 
| 245 | } | ||
| 241 | } | 246 | } | 
| 247 | #ifdef DEVRANDOM | ||
| 248 | /* given that all random loads just fail if the file can't be | ||
| 249 | * seen on a stat, we stat the file we're returning, if it | ||
| 250 | * fails, use DEVRANDOM instead. the allows the user to | ||
| 251 | * use their own source for good random data, but defaults | ||
| 252 | * to something hopefully decent if that isn't available. | ||
| 253 | */ | ||
| 254 | |||
| 255 | if (stat(ret,&sb) == -1) | ||
| 256 | ret = DEVRANDOM; | ||
| 257 | #endif | ||
| 242 | return(ret); | 258 | return(ret); | 
| 243 | } | 259 | } | 
| 260 | |||
