aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/rand/randfile.c
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/rand/randfile.c')
-rw-r--r--crypto/rand/randfile.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index 6829d4ec37..e1ed4e3a98 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -60,12 +60,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/types.h>
#include "openssl/e_os.h"
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef MAC_OS_pre_X
+# include <stat.h>
+#else
+# include <sys/stat.h>
+#endif
+
#include <openssl/rand.h>
#undef BUFSIZE
@@ -116,19 +122,25 @@ int RAND_write_file(const char *file)
FILE *out;
int n;
- /* Under VMS, fopen(file, "wb") will craete a new version of the
+ /* Under VMS, fopen(file, "wb") will create a new version of the
same file. This is not good, so let's try updating an existing
one, and create file only if it doesn't already exist. This
should be completely harmless on system that have no file
versions. -- Richard Levitte */
out=fopen(file,"rb+");
- if (out == NULL && errno == ENOENT)
+ if (out == NULL
+#ifdef ENOENT
+ && errno == ENOENT
+#endif
+ )
{
errno = 0;
out=fopen(file,"wb");
}
if (out == NULL) goto err;
+#ifndef NO_CHMOD
chmod(file,0600);
+#endif
n=RAND_DATA;
for (;;)
{