[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()
{
AssertSize(Game::netadr_t, 20);
@ -372,6 +378,9 @@ namespace Components
// Install packet deploy hook
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::SendRaw(address, address.getString());

View File

@ -58,7 +58,7 @@ namespace Components
static void Handle(const std::string& packet, Utils::Slot<Callback> callback);
static void OnStart(Utils::Slot<CallbackRaw> callback);
// Send quake-styled binary data
static void Send(Address target, const std::string& data);
static void Send(Game::netsrc_t type, Address target, const std::string& data);
@ -88,6 +88,7 @@ namespace Components
static void NetworkStartStub();
static void PacketErrorCheck();
static void NET_DeferPacketToClientStub(Game::netadr_t* from, Game::msg_t* msg);
};
}