Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 329 Lines • ▼ Show 20 Lines | try { | ||||
return set_error(serror, SCRIPT_ERR_PUSH_SIZE); | return set_error(serror, SCRIPT_ERR_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, SCRIPT_ERR_OP_COUNT); | return set_error(serror, SCRIPT_ERR_OP_COUNT); | ||||
} | } | ||||
if (opcode == OP_LEFT || opcode == OP_RIGHT || opcode == OP_INVERT || | if (opcode == OP_RIGHT || opcode == OP_INVERT || opcode == OP_2MUL || | ||||
opcode == OP_2MUL || opcode == OP_2DIV || opcode == OP_MUL || | opcode == OP_2DIV || opcode == OP_MUL || opcode == OP_LSHIFT || | ||||
opcode == OP_LSHIFT || opcode == OP_RSHIFT) { | opcode == OP_RSHIFT) { | ||||
// Disabled opcodes. | // Disabled opcodes. | ||||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); | return set_error(serror, SCRIPT_ERR_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, SCRIPT_ERR_MINIMALDATA); | return set_error(serror, SCRIPT_ERR_MINIMALDATA); | ||||
▲ Show 20 Lines • Show All 933 Lines • ▼ Show 20 Lines | try { | ||||
valtype vchOut1, vchOut2; | valtype vchOut1, vchOut2; | ||||
vchOut1.insert(vchOut1.end(), vch.begin(), vch.begin() + nPosition); | vchOut1.insert(vchOut1.end(), vch.begin(), vch.begin() + nPosition); | ||||
vchOut2.insert(vchOut2.end(), vch.begin() + nPosition, vch.end()); | vchOut2.insert(vchOut2.end(), vch.begin() + nPosition, vch.end()); | ||||
stack.emplace_back(move(vchOut1)); | stack.emplace_back(move(vchOut1)); | ||||
stack.emplace_back(move(vchOut2)); | stack.emplace_back(move(vchOut2)); | ||||
} | } | ||||
} break; | } break; | ||||
// | |||||
// Conversion operations | |||||
// | |||||
case OP_BIN2NUM: { | |||||
// (in -- out) | |||||
if (stack.size() < 1) { | |||||
return set_error( | |||||
serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | |||||
} | |||||
valtype bin = stacktop(-1); | |||||
std::reverse(bin.begin(), bin.end()); // big endian to little endian conversion | |||||
CScriptNum num(bin, false); | |||||
if (num > (INT_MAX>>1) || num < (INT_MIN>>1)) { | |||||
return set_error(serror, SCRIPT_ERR_INVALID_BIN2NUM_OPERATION); | |||||
} | |||||
stack.pop_back(); | |||||
stack.push_back(num.getvch()); | |||||
} break; | |||||
default: | default: | ||||
return set_error(serror, SCRIPT_ERR_BAD_OPCODE); | return set_error(serror, SCRIPT_ERR_BAD_OPCODE); | ||||
} | } | ||||
// Size limits | // Size limits | ||||
if (stack.size() + altstack.size() > 1000) { | if (stack.size() + altstack.size() > 1000) { | ||||
return set_error(serror, SCRIPT_ERR_STACK_SIZE); | return set_error(serror, SCRIPT_ERR_STACK_SIZE); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 437 Lines • Show Last 20 Lines |