mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-11-04 23:29:25 +00:00
win32 port: fix LWIP_RAND() being called without sys_init()
This can happen in tests...
This commit is contained in:
parent
04cf6bbe66
commit
9b5a6fe1dc
@ -78,17 +78,6 @@ static DWORD netconn_sem_tls_index;
|
||||
|
||||
static HCRYPTPROV hcrypt;
|
||||
|
||||
unsigned int
|
||||
lwip_port_rand(void)
|
||||
{
|
||||
u32_t ret;
|
||||
if (CryptGenRandom(hcrypt, sizeof(ret), (BYTE*)&ret)) {
|
||||
return ret;
|
||||
}
|
||||
LWIP_ASSERT("CryptGenRandom failed", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sys_win_rand_init(void)
|
||||
{
|
||||
@ -105,6 +94,22 @@ sys_win_rand_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int
|
||||
lwip_port_rand(void)
|
||||
{
|
||||
u32_t ret;
|
||||
if (CryptGenRandom(hcrypt, sizeof(ret), (BYTE*)&ret)) {
|
||||
return ret;
|
||||
}
|
||||
// maybe CryptAcquireContext has not been called...
|
||||
sys_win_rand_init();
|
||||
if (CryptGenRandom(hcrypt, sizeof(ret), (BYTE*)&ret)) {
|
||||
return ret;
|
||||
}
|
||||
LWIP_ASSERT("CryptGenRandom failed", 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
sys_init_timing(void)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user