From 4259a16931a67df4e6a0592a3328c8d7595c733b Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Thu, 21 May 2026 00:07:25 +0200 Subject: [PATCH] Protect random reseeding with a lock --- cmdline/support.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmdline/support.c b/cmdline/support.c index ddaa0040..fd30cfbb 100644 --- a/cmdline/support.c +++ b/cmdline/support.c @@ -86,12 +86,18 @@ static uint64_t random_state = 1; void random_seed(uint64_t seed) { + lock_random(); random_state = seed; + unlock_random(); } void random_reseed(void) { - random_state = os_tick(); + uint64_t seed = os_tick(); + + lock_random(); + random_state = seed; + unlock_random(); } unsigned char random_u8(void)