From b0d46deef6e6ed62301ea6aa7c0f2d42cc669ef2 Mon Sep 17 00:00:00 2001 From: Jon Shallow Date: Fri, 12 Feb 2021 15:20:35 +0000 Subject: [PATCH] coap_prng.c: Fix missing coap_prng_impl function. PR #590 unfortunately broke the standard builds. --- src/coap_prng.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/coap_prng.c b/src/coap_prng.c index c825dbd6..888a9f03 100644 --- a/src/coap_prng.c +++ b/src/coap_prng.c @@ -39,14 +39,21 @@ coap_prng_impl( unsigned char *buf, size_t len ) { return 1; } -#endif +#endif /* _WIN32 */ static int coap_prng_default(void *buf, size_t len) { #ifdef HAVE_GETRANDOM return getrandom(buf, len, 0); #else /* !HAVE_GETRANDOM */ +#if defined(_WIN32) return coap_prng_impl(buf,len); +#else /* !_WIN32 */ + unsigned char *dst = (unsigned char *)buf; + while (len--) + *dst++ = rand() & 0xFF; + return 1; +#endif /* !_WIN32 */ #endif /* !HAVE_GETRANDOM */ }