Switch for turning on the predictable "random" number generator.
[openssl.git] / crypto / rand / rand_egd.c
index 3a081d4f62fe5d49005f3dc52d33feb756e93177..380c7828c3035b1880bb79e91f48c041ecf657e5 100644 (file)
@@ -59,7 +59,7 @@
 /* Query the EGD <URL: http://www.lothar.com/tech/crypto/>.
  */
 
-#if defined(WIN32) || defined(VMS)
+#if defined(WIN32) || defined(VMS) || defined(__VMS)
 int RAND_egd(const char *path)
        {
        return(-1);
@@ -70,6 +70,7 @@ int RAND_egd(const char *path)
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/un.h>
+#include <string.h>
 
 #ifndef offsetof
 #  define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
@@ -96,6 +97,7 @@ int RAND_egd(const char *path)
        buf[1] = 255;
        write(fd, buf, 2);
        if (read(fd, buf, 1) != 1) goto err;
+       if (buf[0] == 0) goto err;
        num = read(fd, buf, 255);
        if (num < 1) goto err;
        RAND_seed(buf, num);