mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-24 00:46:59 +00:00
fix crash when the header of a TCP packet is negative
This commit is contained in:
@@ -393,6 +393,12 @@ std::vector<uint8_t> TNetwork::TCPRcv(TClient& c) {
|
|||||||
}
|
}
|
||||||
Header = *reinterpret_cast<int32_t*>(HeaderData.data());
|
Header = *reinterpret_cast<int32_t*>(HeaderData.data());
|
||||||
|
|
||||||
|
if (Header < 0) {
|
||||||
|
ClientKick(c, "Invalid packet - header negative");
|
||||||
|
beammp_errorf("Client {} send negative TCP header, ignoring packet", c.GetID());
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> Data;
|
std::vector<uint8_t> Data;
|
||||||
// TODO: This is arbitrary, this needs to be handled another way
|
// TODO: This is arbitrary, this needs to be handled another way
|
||||||
if (Header < int32_t(100 * MB)) {
|
if (Header < int32_t(100 * MB)) {
|
||||||
@@ -425,7 +431,7 @@ std::vector<uint8_t> TNetwork::TCPRcv(TClient& c) {
|
|||||||
void TNetwork::ClientKick(TClient& c, const std::string& R) {
|
void TNetwork::ClientKick(TClient& c, const std::string& R) {
|
||||||
beammp_info("Client kicked: " + R);
|
beammp_info("Client kicked: " + R);
|
||||||
if (!TCPSend(c, StringToVector("K" + R))) {
|
if (!TCPSend(c, StringToVector("K" + R))) {
|
||||||
beammp_debugf("tried to kick player '{}' (id {}), but was already connected", c.GetName(), c.GetID());
|
beammp_debugf("tried to kick player '{}' (id {}), but was already disconnected", c.GetName(), c.GetID());
|
||||||
}
|
}
|
||||||
c.Disconnect("Kicked");
|
c.Disconnect("Kicked");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user