Skip to content

Commit abc484d

Browse files
committed
Improve fill_rand_string
1 parent 6c80a7d commit abc484d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

qtest.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,12 @@ static void fill_rand_string(char *buf, size_t buf_size)
172172
while (len < MIN_RANDSTR_LEN)
173173
len = rand() % buf_size;
174174

175-
randombytes((uint8_t *) buf, len);
175+
uint64_t *randstr_buf_64 = malloc(len * sizeof(uint64_t));
176+
randombytes((uint8_t *) randstr_buf_64, len * sizeof(uint64_t));
176177
for (size_t n = 0; n < len; n++)
177-
buf[n] = charset[buf[n] % (sizeof(charset) - 1)];
178+
buf[n] = charset[randstr_buf_64[n] % (sizeof(charset) - 1)];
179+
180+
free(randstr_buf_64);
178181
buf[len] = '\0';
179182
}
180183

0 commit comments

Comments
 (0)