summaryrefslogtreecommitdiff
path: root/src/librandom
diff options
context:
space:
mode:
Diffstat (limited to 'src/librandom')
-rw-r--r--src/librandom/random_devurandom.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/librandom/random_devurandom.c b/src/librandom/random_devurandom.c
index 0ad752b..5f6b791 100644
--- a/src/librandom/random_devurandom.c
+++ b/src/librandom/random_devurandom.c
@@ -1,6 +1,7 @@
/* ISC license. */
#include <stddef.h>
+#include <errno.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/strerr2.h>
@@ -11,12 +12,15 @@ void random_devurandom (char *s, size_t n)
{
static int random_fd = -1 ;
size_t r ;
+ int e = errno ;
if (random_fd < 0)
{
random_fd = openbc_read("/dev/urandom") ;
if (random_fd < 0)
strerr_diefu2sys(111, "open ", "/dev/urandom") ;
}
+ errno = EPIPE ;
r = allread(random_fd, s, n) ;
if (r < n) strerr_diefu2sys(111, "read from ", "/dev/urandom") ;
+ errno = e ;
}