From a841224683116e75852d6d2ebc9a9f1dc70ec957 Mon Sep 17 00:00:00 2001 From: tux3 Date: Tue, 19 May 2015 20:37:42 +0200 Subject: [PATCH] Use proper random for IPC --- src/ipc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ipc.cpp b/src/ipc.cpp index 28625a50a..d9e82c8de 100644 --- a/src/ipc.cpp +++ b/src/ipc.cpp @@ -12,14 +12,13 @@ See the COPYING file for more details. */ - #include "src/ipc.h" #include "src/misc/settings.h" #include #include +#include #include - IPC::IPC() : globalMemory{"qtox-" IPC_PROTOCOL_VERSION} { @@ -35,8 +34,9 @@ IPC::IPC() // This is a safety measure, in case one of the clients crashes // If the owner exits normally, it can set the timestamp to 0 first to immediately give ownership - qsrand(time(0)); - globalId = ((uint64_t)qrand()) * ((uint64_t)qrand()) * ((uint64_t)qrand()); + std::default_random_engine randEngine((std::random_device()())); + std::uniform_int_distribution distribution; + globalId = distribution(randEngine); qDebug() << "Our global ID is " << globalId; if (globalMemory.create(sizeof(IPCMemory))) {