fix(network): validate and reattempt read if message length is invalid

- Updated `NetworkServer` to validate `messageLength` and reattempt `read` if it exceeds the maximum allowed size.
This commit is contained in:
Kieran Kihn
2025-11-29 18:51:18 +08:00
parent 3dd07e4b20
commit 27cf988ee5

View File

@@ -32,8 +32,11 @@ namespace UNO::NETWORK {
asio::buffer(messageLength.get(), sizeof(size_t)),
[this, self = shared_from_this(), messageLength](const asio::error_code &ec, size_t length) {
if (!ec) {
if (messageLength > 0 && messageLength <= 10 * 1024 * 1024) {
this->readBody(messageLength);
if (*messageLength <= 10 * 1024 * 1024) {
this->readBody(*messageLength);
}
else {
read();
}
}
});