1
0

fix: transaction.py: add extra check to script_GetOp

This commit is contained in:
thecockatiel
2025-01-10 04:14:02 +00:00
committed by SomberNight
parent fefd123275
commit ddb67d9bca

View File

@@ -597,6 +597,7 @@ class BCDataStream(object):
def script_GetOp(_bytes : bytes):
_bytes_len = len(_bytes)
i = 0
while i < len(_bytes):
vch = None
@@ -617,6 +618,10 @@ 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}")
vch = _bytes[i:i + nSize]
i += nSize