From 712f6cfe5411fdbbf46688c22a40fac7e0a8839b Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Tue, 18 Feb 2025 10:20:47 +0100 Subject: reftable/system: introduce `reftable_rand()` Introduce a new system-level `reftable_rand()` function that generates a single unsigned integer for us. The implementation of this function is to be provided by the calling codebase, which allows us to more easily hook into pre-seeded random number generators. Adapt the two callsites where we generated random data. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- reftable/system.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'reftable/system.c') diff --git a/reftable/system.c b/reftable/system.c index adf8e4d30b..e25ccc0da3 100644 --- a/reftable/system.c +++ b/reftable/system.c @@ -4,6 +4,11 @@ #include "../lockfile.h" #include "../tempfile.h" +uint32_t reftable_rand(void) +{ + return git_rand(CSPRNG_BYTES_INSECURE); +} + int tmpfile_from_pattern(struct reftable_tmpfile *out, const char *pattern) { struct tempfile *tempfile; -- cgit v1.3