summaryrefslogtreecommitdiff
path: root/src/librandom
diff options
context:
space:
mode:
Diffstat (limited to 'src/librandom')
-rw-r--r--src/librandom/random_buf_early.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/librandom/random_buf_early.c b/src/librandom/random_buf_early.c
index a7a244d..ce2733b 100644
--- a/src/librandom/random_buf_early.c
+++ b/src/librandom/random_buf_early.c
@@ -15,21 +15,31 @@ void random_buf_early (char *s, size_t n)
#elif defined(SKALIBS_HASGETRANDOM) && defined(SKALIBS_HASGRNDINSECURE)
+#include <errno.h>
#include <sys/random.h>
#include <skalibs/random.h>
void random_buf_early (char *s, size_t n)
{
+ static int broken = 0 ;
+ if (broken) goto bleh ;
while (n)
{
ssize_t r = getrandom(s, n, GRND_INSECURE) ;
- if (r >= 0)
+ if (r == -1)
{
- s += r ;
- n -= r ;
+ if (errno != EINTR) goto breakit ;
+ else continue ;
}
+ s += r ;
+ n -= r ;
}
+ return ;
+ breakit:
+ broken = 1 ;
+ bleh:
+ random_devurandom(s, n) ;
}
#elif defined(SKALIBS_HASDEVURANDOM)