diff options
author | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-08-15 21:35:24 +0000 |
---|---|---|
committer | s_nakamoto <s_nakamoto@1a98c847-1fd6-4fd8-948a-caf3550aa51b> | 2010-08-15 21:35:24 +0000 |
commit | d4c6b90ca3f9b47adb1b2724a0c3514f80635c84 (patch) | |
tree | 130a0b0e35b71736714e6dac7d26a328627a82ca /main.h | |
parent | 4bd188c4383d6e614e18f79dc337fbabe8464c82 (diff) |
fix for block 74638 overflow output transaction
git-svn-id: https://bitcoin.svn.sourceforge.net/svnroot/bitcoin/trunk@132 1a98c847-1fd6-4fd8-948a-caf3550aa51b
Diffstat (limited to 'main.h')
-rw-r--r-- | main.h | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -18,6 +18,7 @@ static const unsigned int MAX_SIZE = 0x02000000; static const unsigned int MAX_BLOCK_SIZE = 1000000;
static const int64 COIN = 100000000;
static const int64 CENT = 1000000;
+static const int64 MAX_MONEY = 21000000 * COIN;
static const int COINBASE_MATURITY = 100;
static const CBigNum bnProofOfWorkLimit(~uint256(0) >> 32);
@@ -471,10 +472,18 @@ public: if (vin.empty() || vout.empty())
return error("CTransaction::CheckTransaction() : vin or vout empty");
- // Check for negative values
+ // Check for negative or overflow output values
+ int64 nValueOut = 0;
foreach(const CTxOut& txout, vout)
+ {
if (txout.nValue < 0)
return error("CTransaction::CheckTransaction() : txout.nValue negative");
+ if (txout.nValue > MAX_MONEY)
+ return error("CTransaction::CheckTransaction() : txout.nValue too high");
+ nValueOut += txout.nValue;
+ if (nValueOut > MAX_MONEY)
+ return error("CTransaction::CheckTransaction() : txout total too high");
+ }
if (IsCoinBase())
{
|