More denial-of-service misbehavior detection: version/addr/inv/getdata messages
This commit is contained in:
parent
3e52aaf212
commit
806704c237
13
src/main.cpp
13
src/main.cpp
@ -1764,7 +1764,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
{
|
{
|
||||||
// Each connection can only send one version message
|
// Each connection can only send one version message
|
||||||
if (pfrom->nVersion != 0)
|
if (pfrom->nVersion != 0)
|
||||||
|
{
|
||||||
|
pfrom->Misbehaving(1);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int64 nTime;
|
int64 nTime;
|
||||||
CAddress addrMe;
|
CAddress addrMe;
|
||||||
@ -1848,6 +1851,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
else if (pfrom->nVersion == 0)
|
else if (pfrom->nVersion == 0)
|
||||||
{
|
{
|
||||||
// Must have a version message before anything else
|
// Must have a version message before anything else
|
||||||
|
pfrom->Misbehaving(1);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1869,7 +1873,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
if (pfrom->nVersion < 31402 && mapAddresses.size() > 1000)
|
if (pfrom->nVersion < 31402 && mapAddresses.size() > 1000)
|
||||||
return true;
|
return true;
|
||||||
if (vAddr.size() > 1000)
|
if (vAddr.size() > 1000)
|
||||||
|
{
|
||||||
|
pfrom->Misbehaving(20);
|
||||||
return error("message addr size() = %d", vAddr.size());
|
return error("message addr size() = %d", vAddr.size());
|
||||||
|
}
|
||||||
|
|
||||||
// Store the new addresses
|
// Store the new addresses
|
||||||
CAddrDB addrDB;
|
CAddrDB addrDB;
|
||||||
@ -1927,7 +1934,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
vector<CInv> vInv;
|
vector<CInv> vInv;
|
||||||
vRecv >> vInv;
|
vRecv >> vInv;
|
||||||
if (vInv.size() > 50000)
|
if (vInv.size() > 50000)
|
||||||
|
{
|
||||||
|
pfrom->Misbehaving(20);
|
||||||
return error("message inv size() = %d", vInv.size());
|
return error("message inv size() = %d", vInv.size());
|
||||||
|
}
|
||||||
|
|
||||||
CTxDB txdb("r");
|
CTxDB txdb("r");
|
||||||
BOOST_FOREACH(const CInv& inv, vInv)
|
BOOST_FOREACH(const CInv& inv, vInv)
|
||||||
@ -1956,7 +1966,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||||||
vector<CInv> vInv;
|
vector<CInv> vInv;
|
||||||
vRecv >> vInv;
|
vRecv >> vInv;
|
||||||
if (vInv.size() > 50000)
|
if (vInv.size() > 50000)
|
||||||
|
{
|
||||||
|
pfrom->Misbehaving(20);
|
||||||
return error("message getdata size() = %d", vInv.size());
|
return error("message getdata size() = %d", vInv.size());
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_FOREACH(const CInv& inv, vInv)
|
BOOST_FOREACH(const CInv& inv, vInv)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user