Reduce version skew: trivia (I hope).
[openssl.git] / crypto / rand / randfile.c
index 678b0fe0d65e5524df0209714b20a245894b4965..7f1428072d27d612b2345353a7c408a68b9d1df7 100644 (file)
@@ -57,7 +57,9 @@
  */
 
 /* We need to define this to get macros like S_IFBLK and S_IFCHR */
+#if !defined(OPENSSL_SYS_VXWORKS)
 #define _XOPEN_SOURCE 500
+#endif
 
 #include <errno.h>
 #include <stdio.h>
@@ -137,14 +139,16 @@ int RAND_load_file(const char *file, long bytes)
        in=fopen(file,"rb");
 #endif
        if (in == NULL) goto err;
-#if defined(S_IFBLK) && defined(S_IFCHR) && !defined(OPNESSL_NO_POSIX_IO)
+#if defined(S_IFBLK) && defined(S_IFCHR) && !defined(OPENSSL_NO_POSIX_IO)
        if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
          /* this file is a device. we don't want read an infinite number
           * of bytes from a random device, nor do we want to use buffered
           * I/O because we will waste system entropy. 
           */
          bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */
+#ifndef OPENSSL_NO_SETVBUF_IONBF
          setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */
+#endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
        }
 #endif
        for (;;)
@@ -310,7 +314,7 @@ const char *RAND_file_name(char *buf, size_t size)
         * to something hopefully decent if that isn't available. 
         */
 
-       if (!ok)
+       if (!buf[0])
                if (BUF_strlcpy(buf,"/dev/arandom",size) >= size) {
                        return(NULL);
                }