Blob Blame History Raw
From fb47a8a6bc8903d8b4b7b71707baa2c7585a0407 Mon Sep 17 00:00:00 2001
From: Tom Gundersen <teg@jklm.no>
Date: Sat, 22 Oct 2011 18:47:08 +0200
Subject: [PATCH] random-seed: convert poolsize from bits to bytes
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
(cherry picked from commit 7c2ec00930ce1f4aabfbb405d84b67eb9d065ef0)
---
 src/random-seed.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/random-seed.c b/src/random-seed.c
index ee5cae3..0c63794 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);
         }
 
-- 
1.7.7.5