[Network] Stops buffer overflow and crash at NET_DeferPacketToClient

- Fixes #17
This commit is contained in:
INeedBots 2020-11-14 02:17:20 -06:00
parent f5aa4f91e0
commit 7aaa64f02d
2 changed files with 11 additions and 1 deletions

View File

@ -336,6 +336,12 @@ namespace Components
} }
} }
void Network::NET_DeferPacketToClientStub(Game::netadr_t* from, Game::msg_t* msg)
{
if (msg->cursize > 0 && msg->cursize <= 1404)
Game::NET_DeferPacketToClient(from, msg);
}
Network::Network() Network::Network()
{ {
AssertSize(Game::netadr_t, 20); AssertSize(Game::netadr_t, 20);
@ -372,6 +378,9 @@ namespace Components
// Install packet deploy hook // Install packet deploy hook
Utils::Hook::RedirectJump(0x5AA713, Network::DeployPacketStub); Utils::Hook::RedirectJump(0x5AA713, Network::DeployPacketStub);
// Fix packets causing buffer overflow
Utils::Hook(0x6267E3, Network::NET_DeferPacketToClientStub, HOOK_CALL).install()->quick();
Network::Handle("resolveAddress", [](Address address, const std::string& /*data*/) Network::Handle("resolveAddress", [](Address address, const std::string& /*data*/)
{ {
Network::SendRaw(address, address.getString()); Network::SendRaw(address, address.getString());

View File

@ -88,6 +88,7 @@ namespace Components
static void NetworkStartStub(); static void NetworkStartStub();
static void PacketErrorCheck(); static void PacketErrorCheck();
static void NET_DeferPacketToClientStub(Game::netadr_t* from, Game::msg_t* msg);
}; };
} }