summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-16 21:17:25 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-16 21:17:54 +0000
commit82f38ed87a059a100b8d56150583cb3563962c37 (patch)
tree19435c0ed0a88e4dc051055daa655bfcb69faa19 /util/nvmutil
parent26a2224d82afc6e45568373d6671538be7992bb3 (diff)
cleanup (fix potential overflow in mkstemp)
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 719a4810..5401c2eb 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -3039,10 +3039,9 @@ x_i_mkstemp(char *template)
char *p;
char ch[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- unsigned long chlen;
+ unsigned long r = rlong();
len = xstrxlen(template, PATH_LEN);
- chlen = xstrxlen(ch, 100);
/* find trailing XXXXXX */
if (len < 6)
@@ -3053,7 +3052,7 @@ x_i_mkstemp(char *template)
for (i = 0; i < 100; i++) {
for (j = 0; j < 6; j++)
- p[j] = ch[rlong() % chlen];
+ p[j] = ch[r % (sizeof(ch) - 1)];
fd = open(template, O_RDWR | O_CREAT | O_EXCL, 0600);