Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 133 Lines • ▼ Show 20 Lines | try { | ||||
return set_error(serror, ScriptError::PUSH_SIZE); | return set_error(serror, ScriptError::PUSH_SIZE); | ||||
} | } | ||||
// Note how OP_RESERVED does not count towards the opcode limit. | // Note how OP_RESERVED does not count towards the opcode limit. | ||||
if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) { | if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) { | ||||
return set_error(serror, ScriptError::OP_COUNT); | return set_error(serror, ScriptError::OP_COUNT); | ||||
} | } | ||||
// Some opcodes are disabled. | // Some opcodes are disabled (CVE-2010-5137). | ||||
if (IsOpcodeDisabled(opcode, flags)) { | if (IsOpcodeDisabled(opcode, flags)) { | ||||
return set_error(serror, ScriptError::DISABLED_OPCODE); | return set_error(serror, ScriptError::DISABLED_OPCODE); | ||||
} | } | ||||
if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) { | if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) { | ||||
if (fRequireMinimal && | if (fRequireMinimal && | ||||
!CheckMinimalPush(vchPushValue, opcode)) { | !CheckMinimalPush(vchPushValue, opcode)) { | ||||
return set_error(serror, ScriptError::MINIMALDATA); | return set_error(serror, ScriptError::MINIMALDATA); | ||||
▲ Show 20 Lines • Show All 1,556 Lines • ▼ Show 20 Lines | bool VerifyScript(const CScript &scriptSig, const CScript &scriptPubKey, | ||||
} | } | ||||
if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) { | if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) { | ||||
return set_error(serror, ScriptError::SIG_PUSHONLY); | return set_error(serror, ScriptError::SIG_PUSHONLY); | ||||
} | } | ||||
ScriptExecutionMetrics metrics = {}; | ScriptExecutionMetrics metrics = {}; | ||||
// scriptSig and scriptPubKey must be evaluated sequentially on the same | |||||
// stack rather than being simply concatenated (see CVE-2010-5141) | |||||
std::vector<valtype> stack, stackCopy; | std::vector<valtype> stack, stackCopy; | ||||
if (!EvalScript(stack, scriptSig, flags, checker, metrics, serror)) { | if (!EvalScript(stack, scriptSig, flags, checker, metrics, serror)) { | ||||
// serror is set | // serror is set | ||||
return false; | return false; | ||||
} | } | ||||
if (flags & SCRIPT_VERIFY_P2SH) { | if (flags & SCRIPT_VERIFY_P2SH) { | ||||
stackCopy = stack; | stackCopy = stack; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 93 Lines • Show Last 20 Lines |