Send connman mailing list submissions to
        [email protected]

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
        [email protected]

You can reach the person managing the list at
        [email protected]

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 <[email protected]>
To: Patrik Flykt <[email protected]>
Cc: [email protected]
Subject: [PATCH 09/10] util: Reading from /dev/urandom ignores the
        number of bytes read
Message-ID: <[email protected]>

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
[email protected]
https://lists.01.org/mailman/listinfo/connman


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

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

Reply via email to