Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-25 19:35:57 +00:00
parent 0d86fd38df
commit 50e3b1f45d
+10 -5
View File
@@ -21,11 +21,14 @@
((USE_URANDOM) > 0) ((USE_URANDOM) > 0)
#include <fcntl.h> /* if not arc4random: /dev/urandom */ #include <fcntl.h> /* if not arc4random: /dev/urandom */
#endif #endif
#include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "../include/common.h" #include "../include/common.h"
@@ -42,7 +45,7 @@ rset(void *buf, size_t n)
arc4random_buf(buf, n); arc4random_buf(buf, n);
goto out; goto out;
#else #else
size_t off = errno = 0; size_t off = 0;
ssize_t rc = 0; ssize_t rc = 0;
#if defined(USE_URANDOM) && \ #if defined(USE_URANDOM) && \
@@ -61,11 +64,8 @@ retry_rand:
#error Unsupported operating system (possibly unsecure randomisation) #error Unsupported operating system (possibly unsecure randomisation)
#endif #endif
if (errno == EINTR || if (errno == EINTR ||
errno == EAGAIN) { errno == EAGAIN)
usleep(100);
goto retry_rand; goto retry_rand;
}
goto err; /* possibly unsupported by kernel */ goto err; /* possibly unsupported by kernel */
} }
@@ -73,6 +73,11 @@ retry_rand:
if ((off += (size_t)rc) < n) if ((off += (size_t)rc) < n)
goto retry_rand; goto retry_rand;
#if defined(USE_URANDOM) && \
((USE_URANDOM) > 0)
close_no_err(&fd);
#endif
goto out; goto out;
err: err:
err_no_cleanup(1, ECANCELED, err_no_cleanup(1, ECANCELED,