diff options
author | Ulf Möller <ulf@openssl.org> | 2000-01-21 01:15:56 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 2000-01-21 01:15:56 +0000 |
commit | e7f97e2d22e386df60c8da63277727a931bf22b7 (patch) | |
tree | 45c42494189d95fada508ac3ff806dee37c00d22 /crypto/rand/randfile.c | |
parent | 731d9c5fb5d0535e3c84866e3c355cbf21a92a67 (diff) |
Check RAND_bytes() return value or use RAND_pseudo_bytes().
Diffstat (limited to 'crypto/rand/randfile.c')
-rw-r--r-- | crypto/rand/randfile.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index 97c3ece535..f95ecb0e00 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -118,7 +118,7 @@ err: int RAND_write_file(const char *file) { unsigned char buf[BUFSIZE]; - int i,ret=0; + int i,ret=0,err=0; FILE *out = NULL; int n; @@ -156,7 +156,8 @@ int RAND_write_file(const char *file) { i=(n > BUFSIZE)?BUFSIZE:n; n-=BUFSIZE; - RAND_bytes(buf,i); + if (RAND_bytes(buf,i) <= 0) + err=1; i=fwrite(buf,1,i,out); if (i <= 0) { @@ -169,7 +170,7 @@ int RAND_write_file(const char *file) fclose(out); memset(buf,0,BUFSIZE); err: - return(ret); + return(err ? -1 : ret); } char *RAND_file_name(char *buf, int size) |