summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2022-12-03 11:55:38 +0000
committerLeah Rowe <leah@libreboot.org>2022-12-03 11:55:38 +0000
commite2e321fc2013086f0bdb6a011159f201a06d1b06 (patch)
treead1c42cee13b20b7c4576e694c0f37bd95055fb8 /util
parenta6d0112d863c6ab0be806f36823b584c48636a52 (diff)
util/nvmutil: use BUFSIZ for rmac size in hextonum
I will be using this function elsewhere, and in general I want this to be usable for lots of programs.
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 11484533..4a021654 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -219,18 +219,18 @@ hextonum(char chs)
uint8_t val8, ch;
static int macfd;
static uint8_t *rmac = NULL;
- static int random;
- if (random > 11) {
+ static size_t random;
+ if (random == BUFSIZ) {
close(macfd);
free(rmac);
rmac = NULL;
}
if (rmac == NULL) {
random = 0;
- if ((rmac = (uint8_t *) malloc(12)) == NULL)
+ if ((rmac = (uint8_t *) malloc(BUFSIZ)) == NULL)
err(1, NULL);
- if (readFromFile(&macfd, rmac, "/dev/urandom", O_RDONLY, 12)
- != 12) {
+ if (readFromFile(&macfd, rmac, "/dev/urandom", O_RDONLY,
+ BUFSIZ) != BUFSIZ) {
warn("%s", "/dev/urandom");
return 16;
}