mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-15 20:30:17 +01:00
Merge pull request #165 from Christewart/script_parse_bug
overflow bug fix didn't quite account for every overflow possibility
This commit is contained in:
commit
bd7f66dc7b
1 changed files with 2 additions and 3 deletions
|
@ -219,12 +219,11 @@ sealed abstract class ScriptParser extends Factory[List[ScriptToken]] {
|
||||||
val uInt32Push = UInt32(BitcoinSUtil.flipEndianness(scriptConstantHex))
|
val uInt32Push = UInt32(BitcoinSUtil.flipEndianness(scriptConstantHex))
|
||||||
//need this for the case where we have an OP_PUSHDATA4 with a number larger than a int32 can hold
|
//need this for the case where we have an OP_PUSHDATA4 with a number larger than a int32 can hold
|
||||||
//TODO: Review this more, see this transaction's scriptSig as an example: b30d3148927f620f5b1228ba941c211fdabdae75d0ba0b688a58accbf018f3cc
|
//TODO: Review this more, see this transaction's scriptSig as an example: b30d3148927f620f5b1228ba941c211fdabdae75d0ba0b688a58accbf018f3cc
|
||||||
val bytesForPushOp = Try(uInt32Push.toInt).getOrElse(Int.MaxValue)
|
val bytesForPushOp = Try(uInt32Push.toInt).getOrElse(tail.size)
|
||||||
val bytesToPushOntoStack = ScriptConstant(scriptConstantHex)
|
val bytesToPushOntoStack = ScriptConstant(scriptConstantHex)
|
||||||
val endIndex = {
|
val endIndex = {
|
||||||
val idx = bytesForPushOp + numBytes
|
val idx = bytesForPushOp + numBytes
|
||||||
//for the case of an overflow. Just assume Int.MaxValue for slice operation which only takes a Int
|
if (idx >= numBytes) idx else tail.size
|
||||||
if (idx >= 0) idx else Int.MaxValue
|
|
||||||
}
|
}
|
||||||
val scriptConstantBytes = tail.slice(numBytes, endIndex)
|
val scriptConstantBytes = tail.slice(numBytes, endIndex)
|
||||||
val scriptConstant = ScriptConstant(scriptConstantBytes)
|
val scriptConstant = ScriptConstant(scriptConstantBytes)
|
||||||
|
|
Loading…
Add table
Reference in a new issue