feat: enable OP_CAT in tapscript

This commit is contained in:
nandhh 2024-08-12 16:50:24 +08:00
parent 539f991ece
commit bcd6383f3b
2 changed files with 25 additions and 3 deletions

View File

@ -451,10 +451,16 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) {
return set_error(serror, SCRIPT_ERR_OP_COUNT);
}
// When OP_SUCCESS disabled opcodes (CVE-2010-5137) are
// redefined in tapscript, remove them from the if below
// and put them here
if (opcode == OP_CAT) {
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes (CVE-2010-5137).
}
}
if (opcode == OP_CAT ||
opcode == OP_SUBSTR ||
if (opcode == OP_SUBSTR ||
opcode == OP_LEFT ||
opcode == OP_RIGHT ||
opcode == OP_INVERT ||
@ -1213,6 +1219,22 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
}
break;
//
// Byte string operations
//
case OP_CAT:
{
if (stack.size() < 2)
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
valtype& vch1 = stacktop(-2);
valtype& vch2 = stacktop(-1);
if (vch1.size() + vch2.size() > MAX_SCRIPT_ELEMENT_SIZE)
return set_error(serror, SCRIPT_ERR_PUSH_SIZE);
vch1.insert(vch1.end(), vch2.begin(), vch2.end());
popstack(stack);
}
break;
default:
return set_error(serror, SCRIPT_ERR_BAD_OPCODE);
}

View File

@ -334,7 +334,7 @@ bool GetScriptOp(CScriptBase::const_iterator& pc, CScriptBase::const_iterator en
bool IsOpSuccess(const opcodetype& opcode)
{
return opcode == 80 || opcode == 98 || (opcode >= 126 && opcode <= 129) ||
return opcode == 80 || opcode == 98 || (opcode >= 127 && opcode <= 129) ||
(opcode >= 131 && opcode <= 134) || (opcode >= 137 && opcode <= 138) ||
(opcode >= 141 && opcode <= 142) || (opcode >= 149 && opcode <= 153) ||
(opcode >= 187 && opcode <= 254);