Commit 8eb2b50a authored by Vladislav Yarmak's avatar Vladislav Yarmak

ap: ensure only one occurence

parent 0ea72270
...@@ -59,6 +59,9 @@ class ExtractException(Exception): ...@@ -59,6 +59,9 @@ class ExtractException(Exception):
class PatternNotFoundException(Exception): class PatternNotFoundException(Exception):
pass pass
class MultipleOccurencesException(Exception):
pass
class UnknownPlatformException(Exception): class UnknownPlatformException(Exception):
pass pass
...@@ -130,9 +133,11 @@ def make_patch(archive, *, ...@@ -130,9 +133,11 @@ def make_patch(archive, *,
sevenzip=sevenzip) as tgt: sevenzip=sevenzip) as tgt:
f = expand(tgt, sevenzip=sevenzip) f = expand(tgt, sevenzip=sevenzip)
offset = f.find(search) offset = f.find(search)
del f
if offset == -1: if offset == -1:
raise PatternNotFoundException("Pattern not found.") raise PatternNotFoundException("Pattern not found.")
if f[offset+len(search):].find(search) != -1:
raise MultipleOccurencesException("Multiple occurences of pattern found!")
del f
print("Pattern found @ %016X" % (offset,), file=sys.stderr) print("Pattern found @ %016X" % (offset,), file=sys.stderr)
res = [] res = []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment