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.
This commit is contained in:
Sylvain Rochet 2020-10-27 21:48:21 +01:00
parent e239222775
commit 332119d7e0

View File

@ -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 */