Skip to content

Commit f8e6fb1

Browse files
committed
Introduce constant for maximum CScript length
1 parent c4e8390 commit f8e6fb1

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/script/interpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
247247
vector<bool> vfExec;
248248
vector<valtype> altstack;
249249
set_error(serror, SCRIPT_ERR_UNKNOWN_ERROR);
250-
if (script.size() > 10000)
250+
if (script.size() > MAX_SCRIPT_SIZE)
251251
return set_error(serror, SCRIPT_ERR_SCRIPT_SIZE);
252252
int nOpCount = 0;
253253
bool fRequireMinimal = (flags & SCRIPT_VERIFY_MINIMALDATA) != 0;

src/script/script.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ static const int MAX_OPS_PER_SCRIPT = 201;
2727
// Maximum number of public keys per multisig
2828
static const int MAX_PUBKEYS_PER_MULTISIG = 20;
2929

30+
// Maximum script length in bytes
31+
static const int MAX_SCRIPT_SIZE = 10000;
32+
3033
// Threshold for nLockTime: below this value it is interpreted as block number,
3134
// otherwise as UNIX timestamp.
3235
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC

0 commit comments

Comments
 (0)