aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-03-05 04:01:22 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2015-03-06 04:03:17 -0800
commitba04c4a7801e7d68a5e84035b919e5c3626eb7a7 (patch)
treef4719f30e05d9b918ce0175355d81d313526135f /src/net.cpp
parent84a05b843b8ab704266289de67c9779ad733a196 (diff)
downloadbitcoin-ba04c4a7801e7d68a5e84035b919e5c3626eb7a7.tar.xz
Limit message sizes before transfer
This introduces a fixed limit for the size of p2p messages, and enforces it before download.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 3c3666615e..d9f470b9e4 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;