nvmutil: don't read urandom fd if fd not open

yeah. obvious bug

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-18 04:21:18 +00:00
parent 7d5384ebb0
commit 1ecea3247d

View File

@@ -1051,6 +1051,8 @@ rlong(void)
if (fd < 0)
fd = open("/dev/random", O_RDONLY | O_BINARY | O_NONBLOCK);
if (fd > -1) {
nr = rw_file_exact(fd, (unsigned char *)&rval,
sizeof(unsigned long), 0, IO_READ, LOOP_EAGAIN,
LOOP_EINTR, MAX_ZERO_RW_RETRY, OFF_ERR);
@@ -1060,6 +1062,7 @@ rlong(void)
if (nr == sizeof(unsigned long))
return rval;
}
return mix;
}