From 4fe23eccc3a62b02289964391a0cd611db89ed8b Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Thu, 17 Feb 2022 19:18:08 +0100 Subject: ipcpd: Use random buffer for flat address Less code, and less chance of a collision. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- src/ipcpd/unicast/addr-auth/flat.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'src/ipcpd/unicast') diff --git a/src/ipcpd/unicast/addr-auth/flat.c b/src/ipcpd/unicast/addr-auth/flat.c index af245a5d..061cb01f 100644 --- a/src/ipcpd/unicast/addr-auth/flat.c +++ b/src/ipcpd/unicast/addr-auth/flat.c @@ -29,19 +29,11 @@ #define OUROBOROS_PREFIX "flat-addr-auth" #include -#include -#include -#include +#include #include "ipcp.h" #include "flat.h" -#include -#include -#include -#include -#include - #define NAME_LEN 8 struct { @@ -75,13 +67,10 @@ int flat_fini(void) uint64_t flat_address(void) { - struct timespec t; - uint32_t addr; - - clock_gettime(CLOCK_REALTIME, &t); - srand(t.tv_nsec); + uint32_t addr = INVALID_ADDRESS; - addr = (rand() % (RAND_MAX - 1) + 1) & 0xFFFFFFFF; + while (addr == INVALID_ADDRESS) + random_buffer(&addr,sizeof(addr)); return addr; } -- cgit v1.2.3