summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-16 21:06:15 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-26 06:59:42 +0000
commitddb0bc314de7353c2df04a7c09c5028c05cfaec6 (patch)
tree1a31fa4b08ceb33ada6e7b212c9f6b3a850a0325 /util
parentb951ef24337e0c916956b4203c11cf15f30b8911 (diff)
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>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 1f7f4af0..8fff62e4 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -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);