summaryrefslogtreecommitdiffstats
path: root/crypto/openssl/crypto/rand/randfile.c
diff options
context:
space:
mode:
authorkris <kris@FreeBSD.org>2000-11-13 01:03:58 +0000
committerkris <kris@FreeBSD.org>2000-11-13 01:03:58 +0000
commit539b977eff7c71f628cb2a407543a51070b14763 (patch)
tree258f64877cac3711a3434257baddcbae72af2af3 /crypto/openssl/crypto/rand/randfile.c
parent893841d237b49d10e810e8b130839b4b63fd5ab4 (diff)
downloadFreeBSD-src-539b977eff7c71f628cb2a407543a51070b14763.zip
FreeBSD-src-539b977eff7c71f628cb2a407543a51070b14763.tar.gz
Initial import of OpenSSL 0.9.6
Diffstat (limited to 'crypto/openssl/crypto/rand/randfile.c')
-rw-r--r--crypto/openssl/crypto/rand/randfile.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/crypto/openssl/crypto/rand/randfile.c b/crypto/openssl/crypto/rand/randfile.c
index 9ff3974..528e410 100644
--- a/crypto/openssl/crypto/rand/randfile.c
+++ b/crypto/openssl/crypto/rand/randfile.c
@@ -61,8 +61,6 @@
#include <stdlib.h>
#include <string.h>
-#include "openssl/e_os.h"
-
#ifdef VMS
#include <unixio.h>
#endif
@@ -75,6 +73,7 @@
# include <sys/stat.h>
#endif
+#include <openssl/e_os.h>
#include <openssl/crypto.h>
#include <openssl/rand.h>
@@ -130,22 +129,22 @@ 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;
-#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);
@@ -156,7 +155,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)
{
@@ -172,7 +171,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);
@@ -189,7 +188,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)
OpenPOWER on IntegriCloud