util/nvmutil: rename variables in hextonum

fsdg20230625
Leah Rowe 2022-12-03 11:58:07 +00:00
parent e2e321fc20
commit ededa5ddda
1 changed files with 10 additions and 10 deletions

View File

@ -218,18 +218,18 @@ hextonum(char chs)
{ {
uint8_t val8, ch; uint8_t val8, ch;
static int macfd; static int macfd;
static uint8_t *rmac = NULL; static uint8_t *rbuf = NULL;
static size_t random; static size_t rindex;
if (random == BUFSIZ) { if (rindex == BUFSIZ) {
close(macfd); close(macfd);
free(rmac); free(rbuf);
rmac = NULL; rbuf = NULL;
} }
if (rmac == NULL) { if (rbuf == NULL) {
random = 0; rindex = 0;
if ((rmac = (uint8_t *) malloc(BUFSIZ)) == NULL) if ((rbuf = (uint8_t *) malloc(BUFSIZ)) == NULL)
err(1, NULL); err(1, NULL);
if (readFromFile(&macfd, rmac, "/dev/urandom", O_RDONLY, if (readFromFile(&macfd, rbuf, "/dev/urandom", O_RDONLY,
BUFSIZ) != BUFSIZ) { BUFSIZ) != BUFSIZ) {
warn("%s", "/dev/urandom"); warn("%s", "/dev/urandom");
return 16; return 16;
@ -244,7 +244,7 @@ hextonum(char chs)
} else if ((ch >= 'a') && (ch <= 'f')) { } else if ((ch >= 'a') && (ch <= 'f')) {
val8 = ch - 'a' + 10; val8 = ch - 'a' + 10;
} else if (ch == '?') { } else if (ch == '?') {
val8 = rmac[random++] & 0xf; val8 = rbuf[rindex++] & 0xf;
} else { } else {
return 16; return 16;
} }