diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 6459fd55d2a4b..08b18729809d8 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -253,7 +253,7 @@ bool EvalScript(std::vector >& stack, const CScript& std::vector vfExec; std::vector altstack; set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR); - if (script.size() > 10000) + if (script.size() > MAX_SCRIPT_SIZE) return set_error(serror, SCRIPT_ERR_SCRIPT_SIZE); int nOpCount = 0; bool fRequireMinimal = (flags & SCRIPT_VERIFY_MINIMALDATA) != 0; diff --git a/src/script/script.h b/src/script/script.h index c5b623bf46331..15ffd9f7f8eab 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -22,6 +22,9 @@ typedef std::vector valtype; static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes +// Maximum script length in bytes +static const int MAX_SCRIPT_SIZE = 10000; + // Threshold for nLockTime: below this value it is interpreted as block number, // otherwise as UNIX timestamp. static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC