lbutils/rand: close fd on urandom error

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-04-01 14:35:24 +01:00
parent a879114734
commit 9dc141bafa
+8 -5
View File
@@ -175,11 +175,14 @@ retry_rand: {
#error Unsupported operating system (possibly unsecure randomisation) #error Unsupported operating system (possibly unsecure randomisation)
#endif #endif
if (rc < 0) if (rc < 0 || /* syscall fehler */
goto err; /* syscall fehler */ rc == 0) { /* prevent infinite loop on fatal err */
#if defined(USE_URANDOM) && \
if (rc == 0) ((USE_URANDOM) > 0)
goto err; /* prevent infinite loop on fatal err */ close_on_eintr(&fd);
#endif
goto err;
}
if ((off += (size_t)rc) < n) if ((off += (size_t)rc) < n)
goto retry_rand; goto retry_rand;