summaryrefslogtreecommitdiff
path: root/misc/unix/rand.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc/unix/rand.c')
-rw-r--r--misc/unix/rand.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/misc/unix/rand.c b/misc/unix/rand.c
index 94970dccb..b44a3f964 100644
--- a/misc/unix/rand.c
+++ b/misc/unix/rand.c
@@ -85,15 +85,20 @@ APR_DECLARE(apr_status_t) apr_generate_random_bytes(unsigned char *buf,
{
#ifdef DEV_RANDOM
- int rnd;
+ int rnd, rc;
apr_size_t got, tot;
if ((rnd = open(STR(DEV_RANDOM), O_RDONLY)) == -1)
return errno;
- for (tot=0; tot<length; tot += got)
- if ((got = read(rnd, buf+tot, length-tot)) < 0)
+ for (tot=0; tot<length; tot += got) {
+ if ((rc = read(rnd, buf+tot, length-tot)) < 0) {
return errno;
+ }
+ else {
+ got = rc;
+ }
+ }
close(rnd);