diff options
| author | markus <> | 2002-09-05 22:12:12 +0000 |
|---|---|---|
| committer | markus <> | 2002-09-05 22:12:12 +0000 |
| commit | e08fb7998d733407336e83a299f140b0c1d2fcd3 (patch) | |
| tree | 64de5de3b0be4adfc5050b6f785b6975c564b730 /src/lib/libcrypto/rand | |
| parent | b200d1ec45aafc7c92b197a4b605e34834d74f1d (diff) | |
| download | openbsd-e08fb7998d733407336e83a299f140b0c1d2fcd3.tar.gz openbsd-e08fb7998d733407336e83a299f140b0c1d2fcd3.tar.bz2 openbsd-e08fb7998d733407336e83a299f140b0c1d2fcd3.zip | |
merge with 0.9.7-beta1
Diffstat (limited to 'src/lib/libcrypto/rand')
| -rw-r--r-- | src/lib/libcrypto/rand/randfile.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index 4b221e08f5..1c3e68ef31 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c | |||
| @@ -99,12 +99,11 @@ int RAND_load_file(const char *file, long bytes) | |||
| 99 | if (file == NULL) return(0); | 99 | if (file == NULL) return(0); |
| 100 | 100 | ||
| 101 | i=stat(file,&sb); | 101 | i=stat(file,&sb); |
| 102 | if (i < 0) { | 102 | /* If the state fails, put some crap in anyway */ |
| 103 | /* If the state fails, put some crap in anyway */ | 103 | RAND_add(&sb,sizeof(sb),0); |
| 104 | RAND_add(&sb,sizeof(sb),0); | 104 | if (i < 0) return(0); |
| 105 | return(0); | ||
| 106 | } | ||
| 107 | if (bytes == 0) return(ret); | 105 | if (bytes == 0) return(ret); |
| 106 | |||
| 108 | in=fopen(file,"rb"); | 107 | in=fopen(file,"rb"); |
| 109 | if (in == NULL) goto err; | 108 | if (in == NULL) goto err; |
| 110 | if (sb.st_mode & (S_IFBLK | S_IFCHR)) { | 109 | if (sb.st_mode & (S_IFBLK | S_IFCHR)) { |
| @@ -218,12 +217,12 @@ err: | |||
| 218 | 217 | ||
| 219 | const char *RAND_file_name(char *buf, size_t size) | 218 | const char *RAND_file_name(char *buf, size_t size) |
| 220 | { | 219 | { |
| 221 | char *s = NULL; | 220 | char *s=NULL; |
| 222 | int ok = 0; | 221 | int ok = 0; |
| 223 | struct stat sb; | 222 | struct stat sb; |
| 224 | 223 | ||
| 225 | if (issetugid() == 0) | 224 | if (issetugid() == 0) |
| 226 | s = getenv("RANDFILE"); | 225 | s=getenv("RANDFILE"); |
| 227 | if (s != NULL && *s && strlen(s) + 1 < size) | 226 | if (s != NULL && *s && strlen(s) + 1 < size) |
| 228 | { | 227 | { |
| 229 | strlcpy(buf,s,size); | 228 | strlcpy(buf,s,size); |
| @@ -272,4 +271,3 @@ const char *RAND_file_name(char *buf, size_t size) | |||
| 272 | #endif | 271 | #endif |
| 273 | return(buf); | 272 | return(buf); |
| 274 | } | 273 | } |
| 275 | |||
