mirror of
https://github.com/kierankihn/uno-game.git
synced 2025-12-27 02:13:18 +08:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user