aboutsummaryrefslogtreecommitdiffstats
path: root/reftable/stack.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-01-21 08:44:53 -0800
committerJunio C Hamano <gitster@pobox.com>2025-01-21 08:44:53 -0800
commitcb441e1ec3f3cf475d9037a4ce74e8fccd6be7d8 (patch)
tree235fe13d72cc2897e498dbdd5d7a9ab0ad7c5415 /reftable/stack.c
parent57ebdd5af4031ddd0e012e68c5e423fd0671ed8c (diff)
parent0b4f8afef6b744d5aa92883c5a6c1985be67cc7c (diff)
downloadgit-cb441e1ec3f3cf475d9037a4ce74e8fccd6be7d8.tar.gz
Merge branch 'ps/reftable-get-random-fix'
The code to compute "unique" name used git_rand() which can fail or get stuck; the callsite does not require cryptographic security. Introduce the "insecure" mode and use it appropriately. * ps/reftable-get-random-fix: reftable/stack: accept insecure random bytes wrapper: allow generating insecure random bytes
Diffstat (limited to 'reftable/stack.c')
-rw-r--r--reftable/stack.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/reftable/stack.c b/reftable/stack.c
index 531660a49f..572a74e00f 100644
--- a/reftable/stack.c
+++ b/reftable/stack.c
@@ -493,7 +493,7 @@ static int reftable_stack_reload_maybe_reuse(struct reftable_stack *st,
close(fd);
fd = -1;
- delay = delay + (delay * rand()) / RAND_MAX + 1;
+ delay = delay + (delay * git_rand(CSPRNG_BYTES_INSECURE)) / UINT32_MAX + 1;
sleep_millisec(delay);
}
@@ -659,7 +659,7 @@ int reftable_stack_add(struct reftable_stack *st,
static int format_name(struct reftable_buf *dest, uint64_t min, uint64_t max)
{
char buf[100];
- uint32_t rnd = (uint32_t)git_rand();
+ uint32_t rnd = git_rand(CSPRNG_BYTES_INSECURE);
snprintf(buf, sizeof(buf), "0x%012" PRIx64 "-0x%012" PRIx64 "-%08x",
min, max, rnd);
reftable_buf_reset(dest);