]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Prevent players accessing inventories of other players (#10341)
authorLars Müller <34514239+appgurueu@users.noreply.github.com>
Sat, 29 Aug 2020 15:41:03 +0000 (17:41 +0200)
committerGitHub <noreply@github.com>
Sat, 29 Aug 2020 15:41:03 +0000 (16:41 +0100)
src/network/serverpackethandler.cpp

index dcbb114bfe9dc7b9cc1467aa630fd76e0dab8739..abd9deff0a85c853e38caf9a694dce8fa88f20d9 100644 (file)
@@ -630,13 +630,19 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
                if (ma->from_inv != ma->to_inv)
                        m_inventory_mgr->setInventoryModified(ma->to_inv);
 
-               bool from_inv_is_current_player =
-                       (ma->from_inv.type == InventoryLocation::PLAYER) &&
-                       (ma->from_inv.name == player->getName());
-
-               bool to_inv_is_current_player =
-                       (ma->to_inv.type == InventoryLocation::PLAYER) &&
-                       (ma->to_inv.name == player->getName());
+               bool from_inv_is_current_player = false;
+               if (ma->from_inv.type == InventoryLocation::PLAYER) {
+                       if (ma->from_inv.name != player->getName())
+                               return;
+                       from_inv_is_current_player = true;
+               }
+               
+               bool to_inv_is_current_player = false;
+               if (ma->to_inv.type == InventoryLocation::PLAYER) {
+                       if (ma->to_inv.name != player->getName())
+                               return;
+                       to_inv_is_current_player = true;
+               }
 
                InventoryLocation *remote = from_inv_is_current_player ?
                        &ma->to_inv : &ma->from_inv;