From: Tom Gundersen Date: Sat, 22 Oct 2011 16:47:08 +0000 (+0200) Subject: random-seed: convert poolsize from bits to bytes X-Git-Tag: v38~218 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=commitdiff_plain;h=7c2ec00930ce1f4aabfbb405d84b67eb9d065ef0 random-seed: convert poolsize from bits to bytes The problem was first noted in a bug report against Arch's initscripts. Reported-by: Taylan Ulrich Bayırlı Reported-by: Gerardo Exequiel Pozzi --- diff --git a/src/random-seed.c b/src/random-seed.c index ee5cae315..0c63794b6 100644 --- a/src/random-seed.c +++ b/src/random-seed.c @@ -51,7 +51,11 @@ int main(int argc, char *argv[]) { /* Read pool size, if possible */ if ((f = fopen("/proc/sys/kernel/random/poolsize", "re"))) { - fscanf(f, "%zu", &buf_size); + if (fscanf(f, "%zu", &buf_size) > 0) { + /* poolsize is in bits on 2.6, but we want bytes */ + buf_size /= 8; + } + fclose(f); }