Skip to content

Commit

Permalink
Merge #610: All peg-out related detection pushes should be <= OP_PUSH…
Browse files Browse the repository at this point in the history
…DATA4

cff50f5 All peg-out related detection pushes should be <= OP_PUSHDATA4 (Gregory Sanders)

Pull request description:

  related to #598 , #596, #597

  This does not affect consensus, but affects consumers of these parsing rules such as rust-elements.

  cc @apoelstra @roconnor-blockstream

Tree-SHA512: 4ab6f0be52c3804b2af43c7b3eecbbe8f2868d3f33385dc54f3acb0e441188018a2b3df197801f2c20fa96e224b6acacb642ecf2f030227618e0aea1e2da44ea
  • Loading branch information
instagibbs committed Jun 5, 2019
2 parents d8247a4 + cff50f5 commit 1ccb0b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/primitives/pak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash)
std::vector<unsigned char> 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());
Expand Down
11 changes: 9 additions & 2 deletions src/script/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 1ccb0b6

Please sign in to comment.