Commit 52fe4770 by devttys0

Fixed bug in processing internal extractors; if extractor raises an exception,…

Fixed bug in processing internal extractors; if extractor raises an exception, explicitly mark it as failed.
parent c4f37b8e
...@@ -801,9 +801,11 @@ class Magic(object): ...@@ -801,9 +801,11 @@ class Magic(object):
if dlen is None: if dlen is None:
dlen = len(data) dlen = len(data)
sc = 0
for signature in self.signatures: for signature in self.signatures:
# Use regex to search the data block for potential signature # Use regex to search the data block for potential signature
# matches (fast) # matches (fast)
sc += 1
for match in signature.regex.finditer(data): for match in signature.regex.finditer(data):
# Take the offset of the start of the signature into account # Take the offset of the start of the signature into account
offset = match.start() - signature.offset offset = match.start() - signature.offset
...@@ -827,7 +829,7 @@ class Magic(object): ...@@ -827,7 +829,7 @@ class Magic(object):
continue continue
else: else:
self.display_once.add(signature.title) self.display_once.add(signature.title)
# Append the result to the results list # Append the result to the results list
results.append(SignatureResult(**tags)) results.append(SignatureResult(**tags))
......
...@@ -474,7 +474,6 @@ class Module(object): ...@@ -474,7 +474,6 @@ class Module(object):
# as enabled # as enabled
if not self.enabled: if not self.enabled:
self.enabled = True self.enabled = True
self.validate(r) self.validate(r)
self._plugins_result(r) self._plugins_result(r)
......
...@@ -861,6 +861,7 @@ class Extractor(Module): ...@@ -861,6 +861,7 @@ class Extractor(Module):
except KeyboardInterrupt as e: except KeyboardInterrupt as e:
raise e raise e
except Exception as e: except Exception as e:
retval = False
binwalk.core.common.warning("Internal extractor '%s' failed with exception: '%s'" % (str(cmd), str(e))) binwalk.core.common.warning("Internal extractor '%s' failed with exception: '%s'" % (str(cmd), str(e)))
elif cmd: elif cmd:
# If not in debug mode, create a temporary file to redirect # If not in debug mode, create a temporary file to redirect
......
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