mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
Add a valid opcode sanity check to CScript
Added a function in CScript that checks if the script contains valid opcodes. Add a test for that function
This commit is contained in:
@@ -267,3 +267,15 @@ std::string CScriptWitness::ToString() const
|
||||
}
|
||||
return ret + ")";
|
||||
}
|
||||
|
||||
bool CScript::HasValidOps() const
|
||||
{
|
||||
CScript::const_iterator it = begin();
|
||||
while (it < end()) {
|
||||
opcodetype opcode;
|
||||
if (!GetOp(it, opcode) || opcode > 0xb9) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user