From 4f18bce545b3683efaaa27797c26120c865ac704 Mon Sep 17 00:00:00 2001 From: Federico Cecchetto Date: Wed, 2 Mar 2022 00:33:17 +0100 Subject: [PATCH] Fix crash in command handling --- src/client/component/network.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/client/component/network.cpp b/src/client/component/network.cpp index cd7abd98..47ca2b20 100644 --- a/src/client/component/network.cpp +++ b/src/client/component/network.cpp @@ -27,12 +27,19 @@ 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()) { return false; } const auto offset = cmd_string.size() + 5; + + if (message->cursize <= offset) + { + return false; + } + const std::string_view data(message->data + offset, message->cursize - offset); handler->second(*address, data);