From c6a0095ad307a43fc83497bbb3efbc60052f6ada Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 17 Jan 2017 15:56:59 +0300 Subject: - constructor & destructor for NetlibBoundPort - warning fix - randomizer must work even if the system service doesn't exist --- src/mir_core/src/utils.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/mir_core') diff --git a/src/mir_core/src/utils.cpp b/src/mir_core/src/utils.cpp index e2dea519ab..7b26bb6aab 100644 --- a/src/mir_core/src/utils.cpp +++ b/src/mir_core/src/utils.cpp @@ -524,8 +524,15 @@ PGENRANDOM pfnRtlGenRandom; MIR_CORE_DLL(void) Utils_GetRandom(void *pszDest, size_t cbLen) { - if (pszDest != 0 || cbLen != 0 && pfnRtlGenRandom != NULL) + if (pszDest == nullptr || cbLen == 0) + return; + + if (pfnRtlGenRandom != NULL) pfnRtlGenRandom(pszDest, (ULONG)cbLen); - else - memset(pszDest, 0, cbLen); + else { + srand(time(NULL)); + BYTE *p = (BYTE*)pszDest; + for (size_t i = 0; i < cbLen; i++) + p[i] = rand() & 0xFF; + } } -- cgit v1.2.3