From 922344e81e91b1c5f686bdd9f669d5f884624a69 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 12 Mar 2026 14:13:55 +0000 Subject: util/nvmutil: mitigate fast calls to rand if someone calls rhex fast enough, the timestamp may not change. this mitigates that by adding a counter value to the mix Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 68840789..aa3e9192 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -1032,13 +1032,15 @@ fallback_rand(void) { struct timeval tv; unsigned long mix; + static unsigned long counter = 0; gettimeofday(&tv, NULL); mix = (unsigned long)tv.tv_sec ^ (unsigned long)tv.tv_usec ^ (unsigned long)getpid() - ^ (unsigned long)(uintptr_t)&mix; + ^ (unsigned long)&mix + ^ counter++; return (uint16_t)(mix & 0xf); } -- cgit v1.2.1