mirror of https://github.com/bitcoin/bitcoin
script: return undecodable bytes
This commit is contained in:
parent
614d25c56d
commit
b3a8c40571
|
@ -63,7 +63,8 @@ std::string FormatScript(const CScript& script)
|
|||
}
|
||||
continue;
|
||||
}
|
||||
ret += strprintf("0x%x ", HexStr(std::vector<uint8_t>(it2, script.end())));
|
||||
// Undecodable bytes
|
||||
ret += strprintf("UNPARSABLE:(%x) ", HexStr(std::vector<uint8_t>(it2, script.end())));
|
||||
break;
|
||||
}
|
||||
return ret.substr(0, ret.empty() ? ret.npos : ret.size() - 1);
|
||||
|
@ -169,8 +170,11 @@ std::string ScriptToAsmStr(const CScript& script)
|
|||
if (!str.empty()) {
|
||||
str += " ";
|
||||
}
|
||||
auto start = pc;
|
||||
if (!script.GetOp(pc, opcode, vch)) {
|
||||
return str + "[error]";
|
||||
std::vector<unsigned char> remaining_bytes(start, script.end());
|
||||
str += strprintf("UNPARSABLE(%s)", HexStr(remaining_bytes));
|
||||
break;
|
||||
}
|
||||
str += OpcodeToAsmString(opcode, vch);
|
||||
}
|
||||
|
|
|
@ -318,6 +318,7 @@ bool GetScriptOp(CScriptBase::const_iterator& pc, CScriptBase::const_iterator en
|
|||
if (end - pc < 1)
|
||||
return false;
|
||||
unsigned int opcode = *pc++;
|
||||
opcodeRet = static_cast<opcodetype>(opcode);
|
||||
|
||||
// Immediate operand
|
||||
if (opcode <= OP_PUSHDATA4)
|
||||
|
@ -347,14 +348,19 @@ bool GetScriptOp(CScriptBase::const_iterator& pc, CScriptBase::const_iterator en
|
|||
nSize = ReadLE32(&pc[0]);
|
||||
pc += 4;
|
||||
}
|
||||
if (end - pc < 0 || (unsigned int)(end - pc) < nSize)
|
||||
|
||||
// Fail if there's not enough data
|
||||
unsigned int available_data = static_cast<unsigned int>(end - pc);
|
||||
if (available_data < nSize)
|
||||
{
|
||||
return false;
|
||||
if (pvchRet)
|
||||
pvchRet->assign(pc, pc + nSize);
|
||||
pc += nSize;
|
||||
} else {
|
||||
if (pvchRet)
|
||||
pvchRet->assign(pc, pc + nSize);
|
||||
pc += nSize;
|
||||
}
|
||||
}
|
||||
|
||||
opcodeRet = static_cast<opcodetype>(opcode);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
[
|
||||
"6a02ee",
|
||||
{
|
||||
"asm": "RETURN [error]",
|
||||
"asm": "RETURN UNPARSABLE(02ee)",
|
||||
"desc": "raw(6a02ee)#gvdwnlzl",
|
||||
"type": "nonstandard"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue