diff options
author | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2002-09-13 15:43:30 +0000 |
---|---|---|
committer | trawick <trawick@13f79535-47bb-0310-9956-ffa450edef68> | 2002-09-13 15:43:30 +0000 |
commit | b2cec31b341f7e8e6dffed0f4a5485b3a483257f (patch) | |
tree | 4ec5ae092badbeee131352de6d5af49cea91d1e1 /misc | |
parent | 23f9d6dc00daabca5f62d776040db3e1d5970fb8 (diff) | |
download | libapr-b2cec31b341f7e8e6dffed0f4a5485b3a483257f.tar.gz |
PR:
Fix a broken check for a failure to read from the random device file.
PR: 12615
Submitted by: tenthumbs@cybernex.net
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@63865 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'misc')
-rw-r--r-- | misc/unix/rand.c | 11 |
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); |