[hackers] [sbase][PATCH] libutil/random: cast to long to avoid overflow

From: Elie Le Vaillant <eolien55_AT_disroot.org>
Date: Thu, 7 Mar 2024 17:30:14 +0100

Thanks NRK
---
 libutil/random.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libutil/random.c b/libutil/random.c
index d5214ae..aa98d61 100644
--- a/libutil/random.c
+++ b/libutil/random.c
_AT_@ -67,7 +67,7 @@ rng32_seed_r(uint64_t *state)
 {
 	struct timespec ts;
 	clock_gettime(CLOCK_REALTIME, &ts);
-	*state = (intptr_t)&printf ^ ts.tv_sec ^ (ts.tv_nsec * 0xAC5533CD);
+	*state = (intptr_t)&printf ^ ts.tv_sec ^ ((unsigned long)ts.tv_nsec * 0xAC5533CD);
 }
 
 void
-- 
2.44.0
Received on Thu Mar 07 2024 - 17:30:14 CET

This archive was generated by hypermail 2.3.0 : Thu Mar 07 2024 - 17:36:36 CET