diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-04-01 14:35:24 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-04-01 14:35:24 +0100 |
| commit | 9dc141bafa96a4c78e4783d3cba5bdc990717268 (patch) | |
| tree | 915c09b247cc5a87e1c008219d3fc7fc1abc3dc9 /util/libreboot-utils/lib/rand.c | |
| parent | a879114734c7d0fdd54c58aacf925660a43a06ef (diff) | |
lbutils/rand: close fd on urandom error
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 | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/util/libreboot-utils/lib/rand.c b/util/libreboot-utils/lib/rand.c index a5617b18..02353560 100644 --- a/util/libreboot-utils/lib/rand.c +++ b/util/libreboot-utils/lib/rand.c @@ -175,11 +175,14 @@ retry_rand: { #error Unsupported operating system (possibly unsecure randomisation) #endif - if (rc < 0) - goto err; /* syscall fehler */ - - if (rc == 0) - goto err; /* prevent infinite loop on fatal err */ + if (rc < 0 || /* syscall fehler */ + rc == 0) { /* prevent infinite loop on fatal err */ +#if defined(USE_URANDOM) && \ + ((USE_URANDOM) > 0) + close_on_eintr(&fd); +#endif + goto err; + } if ((off += (size_t)rc) < n) goto retry_rand; |
