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 ee5cae3..0c63794 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);
         }