From 9200bb13d15da4b2a23e6bc92c20e95b74aa2113 Mon Sep 17 00:00:00 2001 From: beck <> Date: Fri, 15 Dec 2000 02:58:47 +0000 Subject: openssl-engine-0.9.6 merge --- src/lib/libcrypto/rand/randfile.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/lib/libcrypto/rand/randfile.c') diff --git a/src/lib/libcrypto/rand/randfile.c b/src/lib/libcrypto/rand/randfile.c index c6ff27be0e..29718bdb9d 100644 --- a/src/lib/libcrypto/rand/randfile.c +++ b/src/lib/libcrypto/rand/randfile.c @@ -61,8 +61,6 @@ #include #include -#include "openssl/e_os.h" - #ifdef VMS #include #endif @@ -75,6 +73,7 @@ # include #endif +#include #include #include @@ -139,7 +138,7 @@ err: int RAND_write_file(const char *file) { unsigned char buf[BUFSIZE]; - int i,ret=0,err=0; + int i,ret=0,rand_err=0; FILE *out = NULL; int n; struct stat sb; @@ -156,18 +155,18 @@ int RAND_write_file(const char *file) } } -#if defined(O_CREAT) && defined(O_EXCL) && !defined(WIN32) +#if defined(O_CREAT) && !defined(WIN32) /* For some reason Win32 can't write to files created this way */ - - /* chmod(..., 0600) is too late to protect the file, - * permissions should be restrictive from the start */ - int fd = open(file, O_CREAT | O_EXCL, 0600); - if (fd != -1) - out = fdopen(fd, "wb"); + + /* chmod(..., 0600) is too late to protect the file, + * permissions should be restrictive from the start */ + int fd = open(file, O_CREAT, 0600); + if (fd != -1) + out = fdopen(fd, "wb"); #endif - if (out == NULL) - out = fopen(file,"wb"); - if (out == NULL) goto err; + if (out == NULL) + out = fopen(file,"wb"); + if (out == NULL) goto err; #ifndef NO_CHMOD chmod(file,0600); @@ -178,7 +177,7 @@ int RAND_write_file(const char *file) i=(n > BUFSIZE)?BUFSIZE:n; n-=BUFSIZE; if (RAND_bytes(buf,i) <= 0) - err=1; + rand_err=1; i=fwrite(buf,1,i,out); if (i <= 0) { @@ -194,7 +193,7 @@ int RAND_write_file(const char *file) { char *tmpf; - tmpf = Malloc(strlen(file) + 4); /* to add ";-1" and a nul */ + tmpf = OPENSSL_malloc(strlen(file) + 4); /* to add ";-1" and a nul */ if (tmpf) { strcpy(tmpf, file); @@ -211,7 +210,7 @@ int RAND_write_file(const char *file) fclose(out); memset(buf,0,BUFSIZE); err: - return(err ? -1 : ret); + return (rand_err ? -1 : ret); } const char *RAND_file_name(char *buf, int size) -- cgit v1.2.3-55-g6feb