Don't cheat: when only getting several bytes from each source, n is incremented
[openssl.git] / crypto / rand / rand_unix.c
index c4aae38..658d35f 100644 (file)
@@ -183,10 +183,13 @@ int RAND_poll(void)
                                && t.tv_usec != 0 && n < ENTROPY_NEEDED);
 
                        close(fd);
-                       RAND_add(tmpbuf,sizeof tmpbuf,n);
-                       memset(tmpbuf,0,n);
                        }
                }
+       if (n > 0)
+               {
+               RAND_add(tmpbuf,sizeof tmpbuf,n);
+               memset(tmpbuf,0,n);
+               }
 #endif
 
        /* put in some default random data, we need more than just this */