summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjirka-h <hladky.jiri@gmail.com>2022-04-07 20:26:47 +0200
committerGitHub <noreply@github.com>2022-04-07 20:26:47 +0200
commitb1af225b3212029dc2972862a2d169168c0c01fc (patch)
tree254ea5d40a1269966e6e1456ea1e85c8245520aa
parentUpdate README.md (diff)
parentRound bits up and target full pool size (diff)
downloadhaveged-b1af225b3212029dc2972862a2d169168c0c01fc.tar.xz
haveged-b1af225b3212029dc2972862a2d169168c0c01fc.zip
Merge pull request #70 from zx2c4-forks/roundup
Round bits up and target full pool size
-rw-r--r--src/haveged.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/haveged.c b/src/haveged.c
index cb88d4a..f668968 100644
--- a/src/haveged.c
+++ b/src/haveged.c
@@ -649,7 +649,7 @@ static void run_daemon( /* RETURN: nothing */
t[1] = time(NULL);
if (t[1] - t[0] > 600) {
/* add entropy on daemon start and then every 600 seconds unconditionally */
- nbytes = poolSize / 2;
+ nbytes = poolSize;
r = (nbytes+sizeof(H_UINT)-1)/sizeof(H_UINT);
fills = h->n_fills;
if (havege_rng(h, (H_UINT *)output->buf, r)<1)
@@ -741,7 +741,7 @@ static void run_daemon( /* RETURN: nothing */
if (ioctl(random_fd, RNDGETENTCNT, &current) == -1)
error_exit("Couldn't query entropy-level from kernel");
/* get number of bytes needed to fill pool */
- nbytes = (poolSize - current)/8;
+ nbytes = (poolSize - current + 7)/8;
if(nbytes<1) continue;
/* get that many random bytes */
r = (nbytes+sizeof(H_UINT)-1)/sizeof(H_UINT);