Skip to content

Commit

Permalink
[Script] Introduce constant for maximum CScript length
Browse files Browse the repository at this point in the history
Backports bitcoin/bitcoin f8e6fb1
  • Loading branch information
random-zebra committed Oct 8, 2019
1 parent adfcb46 commit 4bfc161
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/script/interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
std::vector<bool> vfExec;
std::vector<valtype> 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;
Expand Down
3 changes: 3 additions & 0 deletions src/script/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ typedef std::vector<unsigned char> 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
Expand Down

0 comments on commit 4bfc161

Please sign in to comment.