From 3a556b7cbadfe2e90747083440eed5c9ad1f2032 Mon Sep 17 00:00:00 2001 From: iamunick Date: Tue, 27 May 2014 19:19:42 -0400 Subject: [PATCH] Fix memory exhaustion Truncate messages to the size of the tx in them --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index f84479a..0bd68ac 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3256,6 +3256,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)) {