Skip to content

Commit 3284e6c

Browse files
committed
scripts: search for next position of magic bytes rather than fail
document seek method for next position of magic bytes
1 parent 6e43129 commit 3284e6c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

contrib/linearize/linearize-data.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,11 @@ def run(self):
213213

214214
inMagic = inhdr[:4]
215215
if (inMagic != self.settings['netmagic']):
216-
print("Invalid magic: " + inMagic.hex())
217-
return
216+
# Seek backwards 7 bytes (skipping the first byte in the previous search)
217+
# and continue searching from the new position if the magic bytes are not
218+
# found.
219+
self.inF.seek(-7, os.SEEK_CUR)
220+
continue
218221
inLenLE = inhdr[4:]
219222
su = struct.unpack("<I", inLenLE)
220223
inLen = su[0] - 80 # length without header

0 commit comments

Comments
 (0)