S_IFBLK and S_IFCHR may not exist in some places (like Windows), so
authorRichard Levitte <levitte@openssl.org>
Mon, 26 Jan 2004 23:45:32 +0000 (23:45 +0000)
committerRichard Levitte <levitte@openssl.org>
Mon, 26 Jan 2004 23:45:32 +0000 (23:45 +0000)
let's check for those macros, and if they aren't defined, let's assume
there aren't Unixly devices on this platform.

crypto/rand/randfile.c

index f1f250c5bfbacf62aa82468590da5cb614aa3b57..8b072e0679e0d05d95027a23c75a398b3773b38e 100644 (file)
@@ -110,6 +110,7 @@ int RAND_load_file(const char *file, long bytes)
 
        in=fopen(file,"rb");
        if (in == NULL) goto err;
 
        in=fopen(file,"rb");
        if (in == NULL) goto err;
+#if defined(S_IFBLK) && !defined(S_IFCHR)
        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
        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
@@ -118,6 +119,7 @@ int RAND_load_file(const char *file, long bytes)
          bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */
          setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */
        }
          bytes = (bytes == -1) ? 2048 : bytes; /* ok, is 2048 enough? */
          setvbuf(in, NULL, _IONBF, 0); /* don't do buffered reads */
        }
+#endif
        for (;;)
                {
                if (bytes > 0)
        for (;;)
                {
                if (bytes > 0)
@@ -151,6 +153,7 @@ int RAND_write_file(const char *file)
        
        i=stat(file,&sb);
        if (i != -1) { 
        
        i=stat(file,&sb);
        if (i != -1) { 
+#if defined(S_IFBLK) && !defined(S_IFCHR)
          if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
            /* this file is a device. we don't write back to it. 
             * we "succeed" on the assumption this is some sort 
          if (sb.st_mode & (S_IFBLK | S_IFCHR)) {
            /* this file is a device. we don't write back to it. 
             * we "succeed" on the assumption this is some sort 
@@ -159,6 +162,7 @@ int RAND_write_file(const char *file)
             */
            return(1); 
          }
             */
            return(1); 
          }
+#endif
        }
 
 #if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32)
        }
 
 #if defined(O_CREAT) && !defined(OPENSSL_SYS_WIN32)