]> git.saurik.com Git - apple/securityd.git/blobdiff - src/entropy.cpp
securityd-55199.3.tar.gz
[apple/securityd.git] / src / entropy.cpp
index 83d7d203209a33704ce61ee8fcc807f92007e140..c936d8f5bea3b438247d8a4ac45ae6a43676a8be 100644 (file)
@@ -153,21 +153,23 @@ void EntropyManager::collectEntropy()
        
        int result;
        
-       size_t size = sizeof(mach_timespec_t) * timingsToCollect;
-       
     double bytesRemaining = kBytesOfEntropyToCollect;
     
     int loopCount = 0;
     
     while (bytesRemaining >= 0)
     {
+        size_t size = sizeof(mach_timespec_t) * timingsToCollect;
+        
         result = sysctl(mib,4, buffer, &size, NULL, 0);
         if (result == -1) {
             Syslog::alert("entropy measurement returned no entropy (errno=%d)", errno);
+            sleep(1);
         }
         else if (size == 0)
         {
             Syslog::alert("entropy measurement returned no entropy.");
+            sleep(1);
         }
 
         // remove the non-entropic pieces from the buffer