util/nvmutil: rhex(): fail if errno not zero

The code was only checking whether all of the bytes were read,
but there are other errors that can be caught via errno.

Enforce strict errno handling, when generating random
numbers for command `setmac`.
This commit is contained in:
Leah Rowe
2022-12-07 22:30:55 +00:00
parent 3d01cf28d6
commit 960af2d6e8
+2
View File
@@ -258,6 +258,8 @@ rhex(void)
warn("%s", "/dev/urandom");
return 16;
}
if ((errno != 0))
return 16;
}
return rbuf[rindex++] & 0xf;