diff --git a/src/primitives/pak.cpp b/src/primitives/pak.cpp index 42461b6aef..430e26ccc1 100644 --- a/src/primitives/pak.cpp +++ b/src/primitives/pak.cpp @@ -185,7 +185,7 @@ bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash) std::vector extracted_pubkey_hash; // Get full pubkey - if (!script.GetOp(pc, opcode, data) || opcode != 33 || data.size() != 33) { + if (!script.GetOp(pc, opcode, data) || data.size() != 33 || opcode > OP_PUSHDATA4) { return false; } CPubKey full_pubkey(data.begin(), data.end()); diff --git a/src/script/script.cpp b/src/script/script.cpp index b277b8f2a4..386f9a19a5 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -213,17 +213,24 @@ bool CScript::IsPegoutScript(uint256& genesis_hash, CScript& pegout_scriptpubkey return false; } - if (!GetOp(pc, opcode, data) || data.size() != 32 ) { + if (!GetOp(pc, opcode, data) || data.size() != 32 || opcode > OP_PUSHDATA4) { return false; } genesis_hash = uint256(data); // Read in parent chain destination scriptpubkey - if (!GetOp(pc, opcode, data) || data.size() == 0 ) { + if (!GetOp(pc, opcode, data) || opcode > OP_PUSHDATA4 ) { return false; } pegout_scriptpubkey = CScript(data.begin(), data.end()); + // All extra opcodes must be pushes + while(GetOp(pc, opcode, data)) { + if (opcode > OP_PUSHDATA4) { + return false; + } + } + return true; }