Limit message sizes before transfer
This introduces a fixed limit for the size of p2p messages, and enforces it
before download.
Rebased-From: ba04c4a780
Github-Pull: #5843
This commit is contained in:
parent
c118e9d275
commit
fe3a31384c
|
@ -666,6 +666,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;
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,8 @@ static const int PING_INTERVAL = 2 * 60;
|
||||||
static const int TIMEOUT_INTERVAL = 20 * 60;
|
static const int TIMEOUT_INTERVAL = 20 * 60;
|
||||||
/** The maximum number of entries in an 'inv' protocol message */
|
/** The maximum number of entries in an 'inv' protocol message */
|
||||||
static const unsigned int MAX_INV_SZ = 50000;
|
static const unsigned int MAX_INV_SZ = 50000;
|
||||||
|
/** 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;
|
||||||
/** The maximum number of entries in mapAskFor */
|
/** The maximum number of entries in mapAskFor */
|
||||||
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
|
static const size_t MAPASKFOR_MAX_SZ = MAX_INV_SZ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue