fix: transaction.py: add extra check to script_GetOp
This commit is contained in:
committed by
SomberNight
parent
fefd123275
commit
ddb67d9bca
@@ -597,6 +597,7 @@ class BCDataStream(object):
|
|||||||
|
|
||||||
|
|
||||||
def script_GetOp(_bytes : bytes):
|
def script_GetOp(_bytes : bytes):
|
||||||
|
_bytes_len = len(_bytes)
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(_bytes):
|
while i < len(_bytes):
|
||||||
vch = None
|
vch = None
|
||||||
@@ -617,6 +618,10 @@ def script_GetOp(_bytes : bytes):
|
|||||||
try: (nSize,) = struct.unpack_from('<I', _bytes, i)
|
try: (nSize,) = struct.unpack_from('<I', _bytes, i)
|
||||||
except struct.error: raise MalformedBitcoinScript()
|
except struct.error: raise MalformedBitcoinScript()
|
||||||
i += 4
|
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]
|
vch = _bytes[i:i + nSize]
|
||||||
i += nSize
|
i += nSize
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user