chiark / gitweb /
random-seed: convert poolsize from bits to bytes
authorTom Gundersen <teg@jklm.no>
Sat, 22 Oct 2011 16:47:08 +0000 (18:47 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 1 Nov 2011 13:45:52 +0000 (14:45 +0100)
The problem was first noted in a bug report against Arch's initscripts.

Reported-by: Taylan Ulrich Bayırlı <taylanbayirli@gmail.com>
Reported-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
src/random-seed.c

index ee5cae315c24db36e5a7749a94786275920a8601..0c63794b66839e7cb3fb6f97830ddfc1f003e17b 100644 (file)
@@ -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);
         }