Skip to content
Snippets Groups Projects
Commit b7be61ef authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Adrien Béraud
Browse files

conversation: verify conversationId before cloning

This patch validates the conversationId before proceeding with
cloning. Otherwise, an empty conversationId could lead to
accidental removal of the entire conversations directory.

https://git.jami.net/savoirfairelinux/jami-client-qt/-/issues/1982
Change-Id: I428247498bb7533b12dadb8a479779e228e6dfb6
parent 3f45561a
No related branches found
No related tags found
No related merge requests found
...@@ -2635,6 +2635,12 @@ ConversationRepository::cloneConversation( ...@@ -2635,6 +2635,12 @@ ConversationRepository::cloneConversation(
const std::string& conversationId, const std::string& conversationId,
std::function<void(std::vector<ConversationCommit>)>&& checkCommitCb) std::function<void(std::vector<ConversationCommit>)>&& checkCommitCb)
{ {
// Verify conversationId is not empty to avoid deleting the entire conversations directory
if (conversationId.empty()) {
JAMI_ERROR("[Account {}] Clone conversation with empty conversationId", account->getAccountID());
return nullptr;
}
auto conversationsPath = fileutils::get_data_dir() / account->getAccountID() / "conversations"; auto conversationsPath = fileutils::get_data_dir() / account->getAccountID() / "conversations";
dhtnet::fileutils::check_dir(conversationsPath); dhtnet::fileutils::check_dir(conversationsPath);
auto path = conversationsPath / conversationId; auto path = conversationsPath / conversationId;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment