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)
#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;