Skip to content

Commit 1ccb0b6

Browse files
committed
Merge #610: All peg-out related detection pushes should be <= OP_PUSHDATA4
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
2 parents d8247a4 + cff50f5 commit 1ccb0b6

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/primitives/pak.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ bool ScriptHasValidPAKProof(const CScript& script, const uint256& genesis_hash)
185185
std::vector<unsigned char> extracted_pubkey_hash;
186186

187187
// Get full pubkey
188-
if (!script.GetOp(pc, opcode, data) || opcode != 33 || data.size() != 33) {
188+
if (!script.GetOp(pc, opcode, data) || data.size() != 33 || opcode > OP_PUSHDATA4) {
189189
return false;
190190
}
191191
CPubKey full_pubkey(data.begin(), data.end());

src/script/script.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,24 @@ bool CScript::IsPegoutScript(uint256& genesis_hash, CScript& pegout_scriptpubkey
213213
return false;
214214
}
215215

216-
if (!GetOp(pc, opcode, data) || data.size() != 32 ) {
216+
if (!GetOp(pc, opcode, data) || data.size() != 32 || opcode > OP_PUSHDATA4) {
217217
return false;
218218
}
219219
genesis_hash = uint256(data);
220220

221221
// Read in parent chain destination scriptpubkey
222-
if (!GetOp(pc, opcode, data) || data.size() == 0 ) {
222+
if (!GetOp(pc, opcode, data) || opcode > OP_PUSHDATA4 ) {
223223
return false;
224224
}
225225
pegout_scriptpubkey = CScript(data.begin(), data.end());
226226

227+
// All extra opcodes must be pushes
228+
while(GetOp(pc, opcode, data)) {
229+
if (opcode > OP_PUSHDATA4) {
230+
return false;
231+
}
232+
}
233+
227234
return true;
228235
}
229236

0 commit comments

Comments
 (0)