diff options
| author | Wladimir J. van der Laan <[email protected]> | 2015-03-06 15:30:12 +0100 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2015-03-06 15:31:31 +0100 |
| commit | 51377c2dbe0d71dad953a43187749a38010d1f1f (patch) | |
| tree | 5e6b0f601795a266b3ad4a1ab6e6385dea9966ca | |
| parent | Merge pull request #5813 (diff) | |
| parent | Limit message sizes before transfer (diff) | |
| download | discoin-51377c2dbe0d71dad953a43187749a38010d1f1f.tar.xz discoin-51377c2dbe0d71dad953a43187749a38010d1f1f.zip | |
Merge pull request #5843
ba04c4a Limit message sizes before transfer (Pieter Wuille)
| -rw-r--r-- | src/net.cpp | 5 | ||||
| -rw-r--r-- | src/net.h | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp index 3c3666615..d9f470b9e 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -523,6 +523,11 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes) if (handled < 0) return false; + if (msg.in_data && msg.hdr.nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH) { + LogPrint("net", "Oversized message from peer=%i, disconnecting", GetId()); + return false; + } + pch += handled; nBytes -= handled; @@ -46,6 +46,8 @@ static const int TIMEOUT_INTERVAL = 20 * 60; static const unsigned int MAX_INV_SZ = 50000; /** The maximum number of new addresses to accumulate before announcing. */ static const unsigned int MAX_ADDR_TO_SEND = 1000; +/** Maximum length of incoming protocol messages (no message over 2 MiB is currently acceptable). */ +static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 2 * 1024 * 1024; /** -listen default */ static const bool DEFAULT_LISTEN = true; /** -upnp default */ |