From 33208fb5575d76a19163e830617eaaf32dbacda8 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Sat, 30 Jul 2011 23:01:45 +0200 Subject: Check for duplicate txins in CheckTransaction. --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index b57974f577..dccc1727f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -314,6 +314,15 @@ bool CTransaction::CheckTransaction() const return error("CTransaction::CheckTransaction() : txout total out of range"); } + // Check for duplicate inputs + set vInOutPoints; + BOOST_FOREACH(const CTxIn& txin, vin) + { + if (vInOutPoints.count(txin.prevout)) + return false; + vInOutPoints.insert(txin.prevout); + } + if (IsCoinBase()) { if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100) -- cgit v1.2.3 From 25133bd74b75825e8f2ddf551ca09f4537b73a0f Mon Sep 17 00:00:00 2001 From: Venkatesh Srinivas Date: Sun, 7 Aug 2011 12:19:14 -0400 Subject: Use 'unsigned char' rather than 'char' for pchMessageStart. Regarding https://bitcointalk.org/index.php?topic=28022.0 main.cpp has: "char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 };" Per discussion on the thread linked, leaving the signedness of pchMessageStart is unsafe for values > 0x80. This patch specifies 'unsigned char' in main.cpp and net.h. Signed-off-by: Jeff Garzik --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index b57974f577..4bcb87f614 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1766,7 +1766,7 @@ bool static AlreadyHave(CTxDB& txdb, const CInv& inv) // The message start string is designed to be unlikely to occur in normal data. // The characters are rarely used upper ascii, not valid as UTF-8, and produce // a large 4-byte int at any alignment. -char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 }; +unsigned char pchMessageStart[4] = { 0xf9, 0xbe, 0xb4, 0xd9 }; bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) -- cgit v1.2.3