Browse Source

Avoid attempted reads past end of program image

Previously if what could be a load, store, branch, or call instruction
was located within last two bytes of the program image being
disassembled, the disassembler would try to read out of bounds to get
its address parameter. This change marks such cases as not being valid
instructions.
master
Juhani Krekelä 10 months ago
parent
commit
110280ed5e
  1. 1
      thingamajig_disasm.py

1
thingamajig_disasm.py

@ -45,6 +45,7 @@ def segment(binary, origin):
valid = True
if not opcodes[opcode].rx and rx != 0: valid = False
if not opcodes[opcode].ry and ry != 0: valid = False
if opcodes[opcode].addr and ip + 2 >= len(binary): valid = False
if not valid:
raw = binary[ip:ip + 1]

Loading…
Cancel
Save