aboutsummaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorLars Müller <34514239+appgurueu@users.noreply.github.com>2020-08-29 17:41:03 +0200
committerGitHub <noreply@github.com>2020-08-29 16:41:03 +0100
commit3693b6871eba268ecc79b3f52d00d3cefe761131 (patch)
tree6190f0b057fd8a0259c372fb15f9643e9e546c27 /src/network
parentd28f1b01707dfa15e770096a26495452513bc56f (diff)
downloadminetest-3693b6871eba268ecc79b3f52d00d3cefe761131.tar.gz
minetest-3693b6871eba268ecc79b3f52d00d3cefe761131.tar.bz2
minetest-3693b6871eba268ecc79b3f52d00d3cefe761131.zip
Prevent players accessing inventories of other players (#10341)
Diffstat (limited to 'src/network')
-rw-r--r--src/network/serverpackethandler.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index dcbb114bf..abd9deff0 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -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;