Layers: Add in check and document scanner behaviour

This commit is contained in:
Mike Auty
2021-01-27 12:28:35 +00:00
parent 55bbd115ce
commit 69ca85b50a
2 changed files with 5 additions and 0 deletions
@@ -328,6 +328,9 @@ class DataLayerInterface(interfaces.configuration.ConfigurableInterface, metacla
vollog.debug("Invalid address in layer {} found scanning {} at address {:x}".format(
layer_name, self.name, address))
if len(data) > scanner.chunk_size + scanner.overlap:
vollog.debug("Scan chunk too large: {}".format(hex(len(data))))
progress.value = chunk_end
return list(scanner(data, chunk_end - len(data)))
@@ -21,6 +21,8 @@ class BytesScanner(layers.ScannerInterface):
where the needle is found."""
find_pos = data.find(self.needle)
while find_pos >= 0:
# Ensure that if we're in the overlap, we don't report it
# It'll be returned when the next block is scanned
if find_pos < self.chunk_size:
yield find_pos + data_offset
find_pos = data.find(self.needle, find_pos + 1)