follow-up prev: add testcase and minor formatting
(minor reshuffling of check so that it matches following line and is more clear it is a bounds check)
This commit is contained in:
@@ -597,7 +597,6 @@ class BCDataStream(object):
|
||||
|
||||
|
||||
def script_GetOp(_bytes : bytes):
|
||||
_bytes_len = len(_bytes)
|
||||
i = 0
|
||||
while i < len(_bytes):
|
||||
vch = None
|
||||
@@ -618,10 +617,9 @@ def script_GetOp(_bytes : bytes):
|
||||
try: (nSize,) = struct.unpack_from('<I', _bytes, i)
|
||||
except struct.error: raise MalformedBitcoinScript()
|
||||
i += 4
|
||||
|
||||
if nSize > _bytes_len - i:
|
||||
raise MalformedBitcoinScript(f"Push of data element that is larger than remaining data: {nSize} vs {_bytes_len - i}")
|
||||
|
||||
if i + nSize > len(_bytes):
|
||||
raise MalformedBitcoinScript(
|
||||
f"Push of data element that is larger than remaining data: {nSize} vs {len(_bytes) - i}")
|
||||
vch = _bytes[i:i + nSize]
|
||||
i += nSize
|
||||
|
||||
|
||||
Reference in New Issue
Block a user