diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-25 20:19:18 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-25 20:21:02 +0000 |
| commit | 9a9f8535b1bd294a7153b5bdfb3059ea9052cec7 (patch) | |
| tree | 65e27bcbbec0a511c8409fb224ba87a3f05b8459 | |
| parent | f103b5cf6f817c98f84ea424ec36301af8b7cc37 (diff) | |
lbutils: also check null!
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/libreboot-utils/lib/rand.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/util/libreboot-utils/lib/rand.c b/util/libreboot-utils/lib/rand.c index dccf3646..b1c210c3 100644 --- a/util/libreboot-utils/lib/rand.c +++ b/util/libreboot-utils/lib/rand.c @@ -61,6 +61,9 @@ rset(void *buf, size_t n) { int saved_errno = errno; + if (if_err(buf == NULL, EFAULT)) + goto err; + #if (defined(__OpenBSD__) || defined(__FreeBSD__) || \ defined(__NetBSD__) || defined(__APPLE__) || \ defined(__DragonFly__)) && !(defined(USE_URANDOM) && \ @@ -104,15 +107,14 @@ retry_rand: ((USE_URANDOM) > 0) close_no_err(&fd); #endif - goto out; +#endif +out: + errno = saved_errno; + return; err: err_no_cleanup(1, ECANCELED, "Randomisation failure, possibly unsupported in your kernel."); exit(EXIT_FAILURE); -#endif - -out: - errno = saved_errno; } #endif |
