From 089ea76a6e3623023253e2e031648f8cfdd6e801 Mon Sep 17 00:00:00 2001 From: b1rdG Date: Sun, 17 May 2020 09:18:12 -0500 Subject: [PATCH 1/2] Add lobby_identity check --- libretroshare/src/chat/distributedchat.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index 0aa16b20e..97654e200 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -1606,6 +1606,13 @@ ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_nam { RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ + if (!rsIdentity->isOwnId(lobby_identity)) + { + RsErr() << __PRETTY_FUNCTION__ << " lobby_identity RsGxsId id must be own" << std::endl; + lobby_id = 00000000000000000000; + return lobby_id; + } + // create a unique id. // do { lobby_id = RSRandom::random_u64() ; } while(_chat_lobbys.find(lobby_id) != _chat_lobbys.end()) ; From dafd975b513c3b7c945181d35f3b8c10cd390476 Mon Sep 17 00:00:00 2001 From: b1rdG Date: Sun, 17 May 2020 14:06:07 -0500 Subject: [PATCH 2/2] Verify before lock the mutex --- libretroshare/src/chat/distributedchat.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/libretroshare/src/chat/distributedchat.cc b/libretroshare/src/chat/distributedchat.cc index 97654e200..3f5ecc74e 100644 --- a/libretroshare/src/chat/distributedchat.cc +++ b/libretroshare/src/chat/distributedchat.cc @@ -1604,15 +1604,14 @@ ChatLobbyId DistributedChatService::createChatLobby(const std::string& lobby_nam #endif ChatLobbyId lobby_id ; { - RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ - if (!rsIdentity->isOwnId(lobby_identity)) { RsErr() << __PRETTY_FUNCTION__ << " lobby_identity RsGxsId id must be own" << std::endl; - lobby_id = 00000000000000000000; - return lobby_id; + return 0; } + RsStackMutex stack(mDistributedChatMtx); /********** STACK LOCKED MTX ******/ + // create a unique id. // do { lobby_id = RSRandom::random_u64() ; } while(_chat_lobbys.find(lobby_id) != _chat_lobbys.end()) ;