Skip to content

Commit

Permalink
Fix memory exhaustion
Browse files Browse the repository at this point in the history
Truncate messages to the size of the tx in them
  • Loading branch information
Tranz5 committed May 20, 2014
1 parent da048f5 commit 45a18e4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3377,6 +3377,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
CInv inv(MSG_TX, tx.GetHash());
pfrom->AddInventoryKnown(inv);

// Truncate messages to the size of the tx in them
unsigned int nSize = ::GetSerializeSize(tx,SER_NETWORK, PROTOCOL_VERSION);
if (nSize < vMsg.size())
vMsg.resize(nSize);

bool fMissingInputs = false;
if (tx.AcceptToMemoryPool(txdb, true, &fMissingInputs))
{
Expand Down

0 comments on commit 45a18e4

Please sign in to comment.