aboutsummaryrefslogtreecommitdiff
path: root/src/script/bitcoinconsensus.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-11-07 13:40:19 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2016-11-07 13:41:39 +0100
commit8c6218a28ae8941fc07cc1324ade9588e1ffd4d9 (patch)
treed4f00665677d602641791b631e29ee37acac4fcf /src/script/bitcoinconsensus.cpp
parent3c03dc2cfc07077aabef4c0fdd31435842a26a77 (diff)
parent5ca8ef299a08aae91d5061750533694b58d810b2 (diff)
Merge #8976: libconsensus: Add input validation of flags
5ca8ef2 libconsensus: Add input validation of flags (Wladimir J. van der Laan)
Diffstat (limited to 'src/script/bitcoinconsensus.cpp')
-rw-r--r--src/script/bitcoinconsensus.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/script/bitcoinconsensus.cpp b/src/script/bitcoinconsensus.cpp
index b629f4278b..1d0ca0c5ac 100644
--- a/src/script/bitcoinconsensus.cpp
+++ b/src/script/bitcoinconsensus.cpp
@@ -69,10 +69,19 @@ struct ECCryptoClosure
ECCryptoClosure instance_of_eccryptoclosure;
}
+/** Check that all specified flags are part of the libconsensus interface. */
+static bool verify_flags(unsigned int flags)
+{
+ return (flags & ~(bitcoinconsensus_SCRIPT_FLAGS_VERIFY_ALL)) == 0;
+}
+
static int verify_script(const unsigned char *scriptPubKey, unsigned int scriptPubKeyLen, CAmount amount,
const unsigned char *txTo , unsigned int txToLen,
unsigned int nIn, unsigned int flags, bitcoinconsensus_error* err)
{
+ if (!verify_flags(flags)) {
+ return bitcoinconsensus_ERR_INVALID_FLAGS;
+ }
try {
TxInputStream stream(SER_NETWORK, PROTOCOL_VERSION, txTo, txToLen);
CTransaction tx;