Send connman mailing list submissions to
        connman@lists.01.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
        connman-requ...@lists.01.org

You can reach the person managing the list at
        connman-ow...@lists.01.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."


Today's Topics:

   1. [PATCH 09/10] util: Reading from /dev/urandom ignores the
      number of bytes read (Peter Meerwald-Stadler)


----------------------------------------------------------------------

Message: 1
Date: Sat, 15 Oct 2016 12:35:13 +0200
From: Peter Meerwald-Stadler <pme...@pmeerw.net>
To: Patrik Flykt <patrik.fl...@linux.intel.com>
Cc: connman@lists.01.org
Subject: [PATCH 09/10] util: Reading from /dev/urandom ignores the
        number of bytes read
Message-ID: <1476527714-897-10-git-send-email-pme...@pmeerw.net>

falling back to random()

CID 1352469
---
 src/util.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/util.c b/src/util.c
index d9cb905..e6532c8 100644
--- a/src/util.c
+++ b/src/util.c
@@ -40,15 +40,20 @@ static int f = -1;
 
 int __connman_util_get_random(uint64_t *val)
 {
-       int r = 0;
+       int r;
 
        if (!val)
                return -EINVAL;
 
-       if (read(f, val, sizeof(uint64_t)) < 0) {
+       r = read(f, val, sizeof(uint64_t));
+       if (r < 0) {
                r = -errno;
                connman_warn_once("Could not read from "URANDOM);
                *val = random();
+       } else if (r != sizeof(uint64_t)) {
+               r = -EIO;
+               connman_warn_once("Short read from "URANDOM);
+               *val = random();
        }
 
        return r;
-- 
2.7.4



------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
connman@lists.01.org
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 12, Issue 20
***************************************

Reply via email to