From 7ece76857805a3e6a8d70290a084632d3e3fa7e0 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 5 Apr 2022 21:39:43 +0200 Subject: [PATCH] Seed the PRNG even if time() isn't available time() is only needed to seed the PRNG non-deterministically. If it isn't available, do seed it, but pick a static seed. Signed-off-by: Andrzej Kurek --- programs/test/udp_proxy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c index 9a6087c72..a50da1a3f 100644 --- a/programs/test/udp_proxy.c +++ b/programs/test/udp_proxy.c @@ -827,7 +827,6 @@ int main( int argc, char *argv[] ) get_options( argc, argv ); -#if defined(MBEDTLS_HAVE_TIME) /* * Decisions to drop/delay/duplicate packets are pseudo-random: dropping * exactly 1 in N packets would lead to problems when a flight has exactly @@ -838,12 +837,15 @@ int main( int argc, char *argv[] ) */ if( opt.seed == 0 ) { +#if defined(MBEDTLS_HAVE_TIME) opt.seed = (unsigned int) mbedtls_time( NULL ); +#else + opt.seed = 1; +#endif /* MBEDTLS_HAVE_TIME */ mbedtls_printf( " . Pseudo-random seed: %u\n", opt.seed ); } srand( opt.seed ); -#endif /* MBEDTLS_HAVE_TIME */ /* * 0. "Connect" to the server