Limit message sizes before transfer
This introduces a fixed limit for the size of p2p messages, and enforces it before download.
This commit is contained in:
parent
84a05b843b
commit
ba04c4a780
2 changed files with 7 additions and 0 deletions
|
@ -523,6 +523,11 @@ bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes)
|
||||||
if (handled < 0)
|
if (handled < 0)
|
||||||
return false;
|
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;
|
pch += handled;
|
||||||
nBytes -= handled;
|
nBytes -= handled;
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,8 @@ static const int TIMEOUT_INTERVAL = 20 * 60;
|
||||||
static const unsigned int MAX_INV_SZ = 50000;
|
static const unsigned int MAX_INV_SZ = 50000;
|
||||||
/** The maximum number of new addresses to accumulate before announcing. */
|
/** The maximum number of new addresses to accumulate before announcing. */
|
||||||
static const unsigned int MAX_ADDR_TO_SEND = 1000;
|
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 */
|
/** -listen default */
|
||||||
static const bool DEFAULT_LISTEN = true;
|
static const bool DEFAULT_LISTEN = true;
|
||||||
/** -upnp default */
|
/** -upnp default */
|
||||||
|
|
Loading…
Reference in a new issue