diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-25 19:35:57 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-26 06:59:42 +0000 |
| commit | 50e3b1f45d13a6ebb662eee8adddcc58e385698b (patch) | |
| tree | ebd1cc0aa1390d9994702d6db649f78ade81fc14 /util/libreboot-utils/lib/rand.c | |
| parent | 0d86fd38df19589afe98aa7d75cdd4460b678b49 (diff) | |
cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/libreboot-utils/lib/rand.c')
| -rw-r--r-- | util/libreboot-utils/lib/rand.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/util/libreboot-utils/lib/rand.c b/util/libreboot-utils/lib/rand.c index 11d99ffa..6a9d1671 100644 --- a/util/libreboot-utils/lib/rand.c +++ b/util/libreboot-utils/lib/rand.c @@ -21,11 +21,14 @@ ((USE_URANDOM) > 0) #include <fcntl.h> /* if not arc4random: /dev/urandom */ #endif + +#include <fcntl.h> #include <limits.h> #include <stddef.h> #include <string.h> #include <unistd.h> #include <stdlib.h> +#include <string.h> #include "../include/common.h" @@ -42,7 +45,7 @@ rset(void *buf, size_t n) arc4random_buf(buf, n); goto out; #else - size_t off = errno = 0; + size_t off = 0; ssize_t rc = 0; #if defined(USE_URANDOM) && \ @@ -61,11 +64,8 @@ retry_rand: #error Unsupported operating system (possibly unsecure randomisation) #endif if (errno == EINTR || - errno == EAGAIN) { - - usleep(100); + errno == EAGAIN) goto retry_rand; - } goto err; /* possibly unsupported by kernel */ } @@ -73,6 +73,11 @@ retry_rand: if ((off += (size_t)rc) < n) goto retry_rand; +#if defined(USE_URANDOM) && \ + ((USE_URANDOM) > 0) + close_no_err(&fd); +#endif + goto out; err: err_no_cleanup(1, ECANCELED, |
