Skip to content

Commit

Permalink
Merge pull request #173 from wuyihung/improve_fill_rand_string
Browse files Browse the repository at this point in the history
Improve string randomness
  • Loading branch information
jserv authored Mar 20, 2024
2 parents 68b64e3 + d48c56d commit d43e072
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions qtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,11 @@ static void fill_rand_string(char *buf, size_t buf_size)
while (len < MIN_RANDSTR_LEN)
len = rand() % buf_size;

randombytes((uint8_t *) buf, len);
uint64_t randstr_buf_64[MAX_RANDSTR_LEN] = {0};
randombytes((uint8_t *) randstr_buf_64, len * sizeof(uint64_t));
for (size_t n = 0; n < len; n++)
buf[n] = charset[buf[n] % (sizeof(charset) - 1)];
buf[n] = charset[randstr_buf_64[n] % (sizeof(charset) - 1)];

buf[len] = '\0';
}

Expand Down

0 comments on commit d43e072

Please sign in to comment.