From 332119d7e046b3f0781cc61ee592146076546338 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Tue, 27 Oct 2020 21:48:21 +0100 Subject: [PATCH] PPP, magic: dot not assume LWIP_RAND will return 32 bits of randomness Do not assume LWIP_RAND will return 32 bits of randomness because it is probably going to be defined to directly return the rand() value. For example, LCP magic numbers are 32-bit random values. --- src/netif/ppp/magic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/netif/ppp/magic.c b/src/netif/ppp/magic.c index 28961c7b..ce21326b 100644 --- a/src/netif/ppp/magic.c +++ b/src/netif/ppp/magic.c @@ -254,7 +254,7 @@ void magic_randomize(void) { */ u32_t magic(void) { #ifdef LWIP_RAND - return LWIP_RAND() + magic_randomseed; + return (LWIP_RAND() << 16) + LWIP_RAND() + magic_randomseed; #else /* LWIP_RAND */ return ((u32_t)rand() << 16) + (u32_t)rand() + magic_randomseed; #endif /* LWIP_RAND */