Compare commits

...

2 Commits

Author SHA1 Message Date
mckaygerhard e406c1d5f5 antihacks: Protect per-player detached inventory actions
* backported https://github.com/minetest/minetest/pull/10341
  Unfortunately also requires invhack mods to implement workarounds,
  but they seem to already be doing this.
2023-09-17 19:41:41 -04:00
mckaygerhard aa3e2220d6 load warning fix for lua src build in 2023-09-17 17:41:10 -04:00
2 changed files with 13 additions and 7 deletions

View File

@ -73,7 +73,7 @@ static void *ll_load (lua_State *L, const char *path) {
static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
lua_CFunction f = (lua_CFunction)dlsym(lib, sym);
lua_CFunction f = __extension__(lua_CFunction)dlsym(lib, sym);
if (f == NULL) lua_pushstring(L, dlerror());
return f;
}

View File

@ -935,13 +935,19 @@ void Server::handleCommand_InventoryAction(NetworkPacket* pkt)
setInventoryModified(ma->from_inv, false);
setInventoryModified(ma->to_inv, false);
bool from_inv_is_current_player =
(ma->from_inv.type == InventoryLocation::PLAYER) &&
(ma->from_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 =
(ma->to_inv.type == InventoryLocation::PLAYER) &&
(ma->to_inv.name == player->getName());
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;