util/nvmutil: fix mkstemp randomness

i made the string longer, but forgot
to adjust it. the new random function
is also better

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-16 21:06:15 +00:00
parent 5d0d74af4c
commit ea9d108529

View File

@@ -3026,8 +3026,10 @@ x_i_mkstemp(char *template)
char *p;
char ch[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
unsigned long chlen;
len = xstrxlen(template, PATH_LEN);
chlen = xstrxlen(ch, 100);
/* find trailing XXXXXX */
if (len < 6)
@@ -3038,7 +3040,7 @@ x_i_mkstemp(char *template)
for (i = 0; i < 100; i++) {
for (j = 0; j < 6; j++)
p[j] = ch[rlong() & 31];
p[j] = ch[rlong() % chlen];
fd = open(template, O_RDWR | O_CREAT | O_EXCL, 0600);