fix: Reject oversized TMPing messages

This commit is contained in:
Timothy Banks
2026-07-16 20:07:36 +01:00
committed by Ayaz Salikhov
parent d60955e2fc
commit 6c793edf72
2 changed files with 10 additions and 0 deletions

View File

@@ -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

View File

@@ -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)