mirror of
https://github.com/XLabsProject/s1x-client.git
synced 2023-08-02 15:02:12 +02:00
Check msg size in command handling
This commit is contained in:
parent
f589892589
commit
26eeea68e9
@ -121,7 +121,7 @@ namespace auth
|
||||
const auto offset = sizeof("connect") + 4;
|
||||
|
||||
proto::network::connect_info info;
|
||||
if (!info.ParseFromArray(msg->data + offset, msg->cursize - offset))
|
||||
if (msg->cursize < offset || !info.ParseFromArray(msg->data + offset, msg->cursize - offset))
|
||||
{
|
||||
network::send(*from, "error", "Invalid connect data!", '\n');
|
||||
return;
|
||||
|
@ -24,12 +24,12 @@ namespace network
|
||||
const auto cmd_string = utils::string::to_lower(command);
|
||||
auto& callbacks = get_callbacks();
|
||||
const auto handler = callbacks.find(cmd_string);
|
||||
if (handler == callbacks.end())
|
||||
const auto offset = cmd_string.size() + 5;
|
||||
if (message->cursize < offset || handler == callbacks.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto offset = cmd_string.size() + 5;
|
||||
const std::string_view data(message->data + offset, message->cursize - offset);
|
||||
|
||||
handler->second(*address, data);
|
||||
|
Loading…
Reference in New Issue
Block a user