[PATCH] alfred: seed the random() generator for transaction IDs
Sven Eckelmann <[email protected]> Tue, 28 Jul 2026 18:56:01 +0200
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
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")
Signed-off-by: Sven Eckelmann <[email protected]>
---
util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util.c b/util.c
index b00b953..171adb4 100644
--- a/util.c
+++ b/util.c
@@ -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,
--
Sven Eckelmann <[email protected]>