From: Gavin Andresen Date: Mon, 30 Apr 2012 00:56:55 +0000 (-0400) Subject: Check earlier for blocks with duplicate transactions. Fixes #1167 X-Git-Tag: v0.4.0-unstable~129^2~1^2^2~2^2^2~11 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=ad5a4c7c471912aa0bef52c33a1abfb01fe6d89d Check earlier for blocks with duplicate transactions. Fixes #1167 --- diff --git a/src/main.cpp b/src/main.cpp index e6f9421..e8cbc01 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1472,6 +1472,16 @@ bool CBlock::CheckBlock() const if (!tx.CheckTransaction()) return error("CheckBlock() : CheckTransaction failed"); + // Check for duplicate txids. This is caught by ConnectInputs(), + // but catching it earlier avoids a potential DoS attack: + set uniqueTx; + BOOST_FOREACH(const CTransaction& tx, vtx) + { + uniqueTx.insert(tx.GetHash()); + } + if (uniqueTx.size() != vtx.size()) + return error("CheckBlock() : duplicate transaction"); + // Check that it's not full of nonstandard transactions if (GetSigOpCount() > MAX_BLOCK_SIGOPS) return error("CheckBlock() : out-of-bounds SigOpCount");