Skip to content
This repository has been archived by the owner on Nov 15, 2021. It is now read-only.

VM safereadbytes #812

Merged
merged 2 commits into from
Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ All notable changes to this project are documented in this file.
- Update TestNet seeds `#807 <https://github.com/CityOfZion/neo-python/pull/807>`_
- Add Reset logic to NodeLeader such that Blockchain fixture testcases reset properly `#809 <https://github.com/CityOfZion/neo-python/pull/809>`_
- Resolve peewee DeprecationWarning `#810 <https://github.com/CityOfZion/neo-python/pull/810>`_
- Add VM SafeReadBytes `#812 <https://github.com/CityOfZion/neo-python/pull/812>`_


[0.8.2] 2018-10-31
Expand Down
12 changes: 6 additions & 6 deletions neo/VM/ExecutionEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def ExecuteOp(self, opcode, context: ExecutionContext):
astack = context._AltStack

if opcode >= PUSHBYTES1 and opcode <= PUSHBYTES75:
bytestoread = context.OpReader.ReadBytes(int.from_bytes(opcode, 'little'))
bytestoread = context.OpReader.SafeReadBytes(int.from_bytes(opcode, 'little'))
estack.PushT(bytestoread)
else:

Expand All @@ -161,11 +161,11 @@ def ExecuteOp(self, opcode, context: ExecutionContext):

elif opcode == PUSHDATA1:
lenngth = context.OpReader.ReadByte()
estack.PushT(bytearray(context.OpReader.ReadBytes(lenngth)))
estack.PushT(bytearray(context.OpReader.SafeReadBytes(lenngth)))
elif opcode == PUSHDATA2:
estack.PushT(context.OpReader.ReadBytes(context.OpReader.ReadUInt16()))
estack.PushT(context.OpReader.SafeReadBytes(context.OpReader.ReadUInt16()))
elif opcode == PUSHDATA4:
estack.PushT(context.OpReader.ReadBytes(context.OpReader.ReadUInt32()))
estack.PushT(context.OpReader.SafeReadBytes(context.OpReader.ReadUInt32()))
elif opcode in pushops:
topush = int.from_bytes(opcode, 'little') - int.from_bytes(PUSH1, 'little') + 1
estack.PushT(topush)
Expand Down Expand Up @@ -224,7 +224,7 @@ def ExecuteOp(self, opcode, context: ExecutionContext):
if self._Table is None:
return self.VM_FAULT_and_report(VMFault.UNKNOWN2)

script_hash = context.OpReader.ReadBytes(20)
script_hash = context.OpReader.SafeReadBytes(20)

is_normal_call = False
for b in script_hash:
Expand Down Expand Up @@ -919,7 +919,7 @@ def ExecuteOp(self, opcode, context: ExecutionContext):
if opcode in [CALL_ED, CALL_EDT]:
script_hash = estack.Pop().GetByteArray()
else:
script_hash = context.OpReader.ReadBytes(20)
script_hash = context.OpReader.SafeReadBytes(20)

script = self._Table.GetScript(UInt160(data=script_hash).ToBytes())

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mock==2.0.0
mpmath==1.1.0
neo-boa==0.5.6
neo-python-rpc==0.2.1
neocore==0.5.5
neocore==0.5.6
pbr==4.2.0
peewee==3.6.4
pexpect==4.6.0
Expand Down