Skip to contentSkip to conversation

alfred: seed the random() generator for transaction IDs

PATCH New Sven Eckelmann 1 participant 1 message Jul 28

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alfred: seed the random() generator for transaction IDs

time_random_seed() initialized the PRNG with srand(), but the only consumer, get_random_id(), draws its values from random(). srand()/rand() and srandom()/random() are two independent generators which can have separate state; seeding one does not affect the other.

Seed random() with srandom() so the generator that is actually used gets the computed seed.

Fixes fcfe26c690ce ("alfred: Add transaction management block to push_data")
---
 util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util.c +1 -1
index b00b953..171adb4 100644
@@ -47,7 +47,7 @@ void time_random_seed(void)
 		s += c[i];
 	}
 
-	srand(s);
+	srandom(s);
 }
 
 uint16_t get_random_id(void)

---
base-commit: 462a0cf40615f62e0912c36d72a75accbb26f5ee
change-id: 20260728-bugfixes-random-d8ec484f06fa

Best regards,

Signature · 1 line
Sven Eckelmann <[email protected]>