From 960af2d6e8d882d958d25333e7cab864877e37b5 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 7 Dec 2022 22:30:55 +0000 Subject: 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`. --- util/nvmutil/nvmutil.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 6fb0a1d5..759edea0 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -258,6 +258,8 @@ rhex(void) warn("%s", "/dev/urandom"); return 16; } + if ((errno != 0)) + return 16; } return rbuf[rindex++] & 0xf; -- cgit v1.2.1