summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-06 23:50:06 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-06 23:50:06 +0000
commit79c972367e93c42d9a2b14e32bd6e82f5c64de9f (patch)
treeed308747a64077b518a41bb80c3ee2fe0e3f75f6 /util/nvmutil/nvmutil.c
parent6e47315192cf9bd05eb0d228a2b4b145513d933d (diff)
util/nvmutil: reset errno on /dev/random fallback
i didn't catch this before. stale error state would have passed through, even on ultimate success. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index e4fe6c72..1a6f4687 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -358,7 +358,20 @@ open_dev_urandom(void)
/*
* Fall back to /dev/random on old platforms
* where /dev/urandom does not exist.
+ *
+ * In general, we can assume that any system
+ * that would have urandom, probably has the
+ * other device (/dev/urandom).
+ *
+ * Given that on many modern systems, urandom
+ * and random are essentially the same, this
+ * also provides some fault-tolerance there,
+ * while still ultimately being strict under
+ * fallback conditions, thus:
*/
+
+ errno = 0;
+
rname = oldrandom;
xopen(&rfd, rname, O_RDONLY, &st_rfd);
}