mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-16 23:08:49 +02:00
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.
This commit is contained in:
@@ -219,18 +219,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 *rmac = NULL;
|
||||||
static int random;
|
static size_t random;
|
||||||
if (random > 11) {
|
if (random == BUFSIZ) {
|
||||||
close(macfd);
|
close(macfd);
|
||||||
free(rmac);
|
free(rmac);
|
||||||
rmac = NULL;
|
rmac = NULL;
|
||||||
}
|
}
|
||||||
if (rmac == NULL) {
|
if (rmac == NULL) {
|
||||||
random = 0;
|
random = 0;
|
||||||
if ((rmac = (uint8_t *) malloc(12)) == NULL)
|
if ((rmac = (uint8_t *) malloc(BUFSIZ)) == NULL)
|
||||||
err(1, NULL);
|
err(1, NULL);
|
||||||
if (readFromFile(&macfd, rmac, "/dev/urandom", O_RDONLY, 12)
|
if (readFromFile(&macfd, rmac, "/dev/urandom", O_RDONLY,
|
||||||
!= 12) {
|
BUFSIZ) != BUFSIZ) {
|
||||||
warn("%s", "/dev/urandom");
|
warn("%s", "/dev/urandom");
|
||||||
return 16;
|
return 16;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user