diff options
author | George Hazan <ghazan@miranda.im> | 2017-01-17 15:56:59 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-01-17 16:04:21 +0300 |
commit | c6a0095ad307a43fc83497bbb3efbc60052f6ada (patch) | |
tree | 3fe6e293138d9a8713c6b67a3c24a5e57d099343 /src/mir_core | |
parent | 6163df27ad6fd2a5da5d9bbb48bb457d8a07a2b6 (diff) |
- constructor & destructor for NetlibBoundPort
- warning fix
- randomizer must work even if the system service doesn't exist
Diffstat (limited to 'src/mir_core')
-rw-r--r-- | src/mir_core/src/utils.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
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;
+ }
}
|