mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
util/nvmutil: fix randomness in mkstemp
i need to re-initialise r each time. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -2613,7 +2613,7 @@ x_i_mkstemp(char *template)
|
||||
char *p;
|
||||
|
||||
char ch[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
unsigned long r = rlong();
|
||||
unsigned long r;
|
||||
|
||||
len = xstrxlen(template, PATH_LEN);
|
||||
|
||||
@@ -2625,8 +2625,10 @@ x_i_mkstemp(char *template)
|
||||
|
||||
for (i = 0; i < 100; i++) {
|
||||
|
||||
for (j = 0; j < 6; j++)
|
||||
for (j = 0; j < 6; j++) {
|
||||
r = rlong();
|
||||
p[j] = ch[r % (sizeof(ch) - 1)];
|
||||
}
|
||||
|
||||
fd = open(template, O_RDWR | O_CREAT | O_EXCL, 0600);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user