mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 14:20:56 +00:00
fix: Reject oversized TMPing messages
This commit is contained in:
committed by
Ayaz Salikhov
parent
d60955e2fc
commit
6c793edf72
@@ -19,6 +19,9 @@
|
||||
namespace xrpl {
|
||||
|
||||
constexpr std::size_t kMaximumMessageSize = megabytes(64);
|
||||
// Ping messages should be much smaller than the maximum message size,
|
||||
// so we define a separate limit for them.
|
||||
constexpr std::size_t kMaximumPingMessageSize = kilobytes(1);
|
||||
|
||||
// VFALCO NOTE If we forward declare Message and write out shared_ptr
|
||||
// instead of using the in-class type alias, we can remove the
|
||||
|
||||
@@ -359,6 +359,13 @@ invokeProtocolMessage(Buffers const& buffers, Handler& handler, std::size_t& hin
|
||||
return result;
|
||||
}
|
||||
|
||||
if (header->messageType == protocol::mtPING &&
|
||||
header->uncompressedSize + header->headerSize > kMaximumPingMessageSize)
|
||||
{
|
||||
result.second = make_error_code(boost::system::errc::message_size);
|
||||
return result;
|
||||
}
|
||||
|
||||
// We don't have the whole message yet. This isn't an error but we have
|
||||
// nothing to do.
|
||||
if (header->totalWireSize > size)
|
||||
|
||||
Reference in New Issue
Block a user