summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-09 21:08:36 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-09 21:08:36 +0000
commitb5af1bf3acac1383ab23efec05c847851fcce130 (patch)
tree6aa6e914d72190d22a24614eacc0b08ed077f60f /util
parentf8ddb6ef8439a2f5c185ab96dcb412b8dfb04cbb (diff)
util/nvmutil: add guard in rhex()
i removed this before, but it's good to put it here defensively, in case i ever mess up the urandom read function again. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 8a2d6ef0..314d4755 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -973,6 +973,9 @@ rhex(void)
#else
n = (size_t)read_dev_urandom(
urandom_fd, rnum, sizeof(rnum));
+
+ if (!n || n > sizeof(rnum))
+ err(ECANCELED, "Randomisation failure");
#endif
}