aboutsummaryrefslogtreecommitdiffstats
path: root/src/librandom/random_buf_early.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/librandom/random_buf_early.c')
-rw-r--r--src/librandom/random_buf_early.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/librandom/random_buf_early.c b/src/librandom/random_buf_early.c
index d14cd24..8af75b3 100644
--- a/src/librandom/random_buf_early.c
+++ b/src/librandom/random_buf_early.c
@@ -24,6 +24,7 @@ void random_buf_early (char *s, size_t n)
{
static int broken = 0 ;
if (broken) goto bleh ;
+ int e = errno ;
while (n)
{
ssize_t r = getrandom(s, n, GRND_INSECURE) ;
@@ -35,9 +36,11 @@ void random_buf_early (char *s, size_t n)
s += r ;
n -= r ;
}
+ errno = e ;
return ;
breakit:
broken = 1 ;
+ errno = e ;
bleh:
random_devurandom(s, n) ;
}