summaryrefslogtreecommitdiff
path: root/sys/dev/random
diff options
context:
space:
mode:
authorMark Murray <markm@FreeBSD.org>2002-12-12 17:38:45 +0000
committerMark Murray <markm@FreeBSD.org>2002-12-12 17:38:45 +0000
commit340a8a91c378a893b1e15c57f45f4361ab082321 (patch)
treee48a477aa4f72b0c91f8051ae2e00abfbbdc8623 /sys/dev/random
parent8d5d039f80a8d31947f4e84af20e8a56d0009c32 (diff)
Notes
Diffstat (limited to 'sys/dev/random')
-rw-r--r--sys/dev/random/yarrow.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/dev/random/yarrow.c b/sys/dev/random/yarrow.c
index 304de5df0337..1b5a4bfc2294 100644
--- a/sys/dev/random/yarrow.c
+++ b/sys/dev/random/yarrow.c
@@ -253,6 +253,7 @@ read_random_real(void *buf, int count)
static int cur = 0;
static int gate = 1;
static u_char genval[KEYSIZE];
+ size_t tomove;
int i;
int retval;
@@ -270,14 +271,14 @@ read_random_real(void *buf, int count)
random_state.counter[0]++;
yarrow_encrypt(&random_state.key, random_state.counter,
genval);
- memcpy((char *)buf + i, genval,
- sizeof(random_state.counter));
+ tomove = min(count - i, sizeof(random_state.counter));
+ memcpy((char *)buf + i, genval, tomove);
if (++random_state.outputblocks >=
random_state.gengateinterval) {
generator_gate();
random_state.outputblocks = 0;
}
- retval += (int)sizeof(random_state.counter);
+ retval += (int)tomove;
}
}
else {