Skip to content
This repository was archived by the owner on Jul 23, 2021. It is now read-only.

Commit 8ac1b94

Browse files
committed
Update: Add overflow and coinbase TX catches
1 parent 56df7b7 commit 8ac1b94

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

DigitalNote.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
TEMPLATE = app
22
TARGET = DigitalNote-qt
3-
VERSION = 1.0.3.9
3+
VERSION = 1.0.4.0
44
INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor
55
QT += core gui widgets network printsupport
66
DEFINES += ENABLE_WALLET
@@ -25,7 +25,7 @@ BDB_LIB_PATH=C:/deps/db-6.2.32.NC/build_unix
2525
OPENSSL_INCLUDE_PATH=C:/deps/openssl-1.0.2u/include
2626
OPENSSL_LIB_PATH=C:/deps/openssl-1.0.2u
2727
MINIUPNPC_INCLUDE_PATH=C:/deps/
28-
MINIUPNPC_LIB_PATH=C:/deps/miniupnpc
28+
MINIUPNPC_LIB_PATH=C:/deps/miniupnpc-2.1
2929
QRENCODE_INCLUDE_PATH=C:/deps/qrencode-4.0.2
3030
QRENCODE_LIB_PATH=C:/deps/qrencode-4.0.2/.libs
3131
SECP256K1_INCLUDE_PATH=C:/deps/secp256k1/include

src/clientversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
99
#define CLIENT_VERSION_MAJOR 1
1010
#define CLIENT_VERSION_MINOR 0
11-
#define CLIENT_VERSION_REVISION 3
12-
#define CLIENT_VERSION_BUILD 9
11+
#define CLIENT_VERSION_REVISION 4
12+
#define CLIENT_VERSION_BUILD 0
1313

1414
// Set to true for release, false for prerelease or test build
1515
#define CLIENT_VERSION_IS_RELEASE true

src/main.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,12 +1666,18 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map<uint256, CTxIndex>& mapTes
16661666
const CTxOut& CTransaction::GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const
16671667
{
16681668
MapPrevTx::const_iterator mi = inputs.find(input.prevout.hash);
1669-
if (mi == inputs.end())
1669+
if (mi == inputs.end()) {
16701670
throw std::runtime_error("CTransaction::GetOutputFor() : prevout.hash not found");
1671+
}
16711672

16721673
const CTransaction& txPrev = (mi->second).second;
1673-
if (input.prevout.n >= txPrev.vout.size())
1674-
throw std::runtime_error("CTransaction::GetOutputFor() : prevout.n out of range");
1674+
// Don't allow oversized outputs
1675+
if (input.prevout.n >= txPrev.vout.size()) {
1676+
// Skip if input is 0 (coinbase tx!)
1677+
if(!input.prevout.IsNull()) {
1678+
throw std::runtime_error("CTransaction::GetOutputFor() : prevout.n out of range");
1679+
}
1680+
}
16751681

16761682
return txPrev.vout[input.prevout.n];
16771683
}
@@ -2959,6 +2965,11 @@ bool CBlock::AcceptBlock()
29592965
tx_outputs_values += tx.GetValueOut();
29602966
}
29612967

2968+
// Verify we haven't overflowed CAmount value or had NULL inputs/outpus in the block
2969+
if((tx_inputs_values + tx_threshold) <= 0) {
2970+
return DoS(100, error("AcceptBlock() : block contains a tx input that is less that output"));
2971+
}
2972+
29622973
// Ensure input/output sanity of transactions in the block
29632974
if((tx_inputs_values + tx_threshold) < tx_outputs_values)
29642975
{

src/version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static const int DATABASE_VERSION = 70509;
3030
//
3131
// network protocol versioning
3232
//
33-
static const int PROTOCOL_VERSION = 62030;
33+
static const int PROTOCOL_VERSION = 62031;
3434

3535
// intial proto version, to be increased after version/verack negotiation
3636
static const int INIT_PROTO_VERSION = 209;

0 commit comments

Comments
 (0)