diff options
author | Tim Akinbo <41004+takinbo@users.noreply.github.com> | 2019-09-04 07:07:14 +0000 |
---|---|---|
committer | Tim Akinbo <41004+takinbo@users.noreply.github.com> | 2019-09-30 18:10:47 +0000 |
commit | 3284e6c09a84e9557ec72723ad636053d3ef7122 (patch) | |
tree | 34ce4dcb8a2436212072333dab0c14ad1a1ba47e | |
parent | 6e431296daceee604f48e9e3e87fa84cfd44bef2 (diff) |
scripts: search for next position of magic bytes rather than fail
document seek method for next position of magic bytes
-rwxr-xr-x | contrib/linearize/linearize-data.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/contrib/linearize/linearize-data.py b/contrib/linearize/linearize-data.py index 468aec04b5..e0718f1075 100755 --- a/contrib/linearize/linearize-data.py +++ b/contrib/linearize/linearize-data.py @@ -213,8 +213,11 @@ class BlockDataCopier: inMagic = inhdr[:4] if (inMagic != self.settings['netmagic']): - print("Invalid magic: " + inMagic.hex()) - return + # Seek backwards 7 bytes (skipping the first byte in the previous search) + # and continue searching from the new position if the magic bytes are not + # found. + self.inF.seek(-7, os.SEEK_CUR) + continue inLenLE = inhdr[4:] su = struct.unpack("<I", inLenLE) inLen = su[0] - 80 # length without header |