diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-12-25 10:32:05 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-12-25 10:32:05 -0500 |
commit | 61977f956c6bacd6e05e3211bf2a90e5b5672a94 (patch) | |
tree | ebcf6c2f1c8bfcb418d8ee4f4aa35dc752a64d66 /src/main.cpp | |
parent | 60835d96276549ce17fe163a18c2f78dc5b267bc (diff) |
Check all prevout.n if one transaction provides multiple inputs
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0277f5fa75..15f047bf7b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -945,10 +945,18 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTes if (!txPrev.ReadFromDisk(txindex.pos)) return error("FetchInputs() : %s ReadFromDisk prev tx %s failed", GetHash().ToString().substr(0,10).c_str(), prevout.hash.ToString().substr(0,10).c_str()); } + } + + // Make sure all prevout.n's are valid: + for (int i = 0; i < vin.size(); i++) + { + const COutPoint prevout = vin[i].prevout; + const CTxIndex& txindex = inputsRet[prevout.hash].first; + const CTransaction& txPrev = inputsRet[prevout.hash].second; if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %d %d prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); - } + return true; } |