proposed fix for issue 242

This commit is contained in:
Brannon King 2019-09-11 15:11:04 -06:00
parent 8b98a9a4e9
commit 920a9b09dc
2 changed files with 6 additions and 2 deletions

View file

@ -62,6 +62,7 @@ bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector
bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector<unsigned char> >& vvchParams, CScript::const_iterator& pc) bool DecodeClaimScript(const CScript& scriptIn, int& op, std::vector<std::vector<unsigned char> >& vvchParams, CScript::const_iterator& pc)
{ {
op = -1;
opcodetype opcode; opcodetype opcode;
if (!scriptIn.GetOp(pc, opcode)) if (!scriptIn.GetOp(pc, opcode))
{ {

View file

@ -1491,6 +1491,11 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C
return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY); return set_error(serror, SCRIPT_ERR_SIG_PUSHONLY);
} }
int claimOp;
const CScript& strippedScriptPubKey = StripClaimScriptPrefix(scriptPubKey, claimOp);
if (claimOp >= 0) // lbryum used to violate this rule with an off-by-1 at len == 255 (and its not very important)
flags &= ~SCRIPT_VERIFY_MINIMALDATA;
std::vector<std::vector<unsigned char> > stack, stackCopy; std::vector<std::vector<unsigned char> > stack, stackCopy;
if (!EvalScript(stack, scriptSig, flags, checker, SigVersion::BASE, serror)) if (!EvalScript(stack, scriptSig, flags, checker, SigVersion::BASE, serror))
// serror is set // serror is set
@ -1507,8 +1512,6 @@ bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const C
// Bare witness programs // Bare witness programs
const CScript& strippedScriptPubKey = StripClaimScriptPrefix(scriptPubKey);
int witnessversion; int witnessversion;
std::vector<unsigned char> witnessprogram; std::vector<unsigned char> witnessprogram;
if (flags & SCRIPT_VERIFY_WITNESS) { if (flags & SCRIPT_VERIFY_WITNESS) {