mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-08-22 06:22:23 +02:00
Move the length check, and require a non-zero length to protect is_valid.
This commit is contained in:
@@ -80,6 +80,8 @@ class FileLayer(interfaces.layers.DataLayerInterface):
|
||||
|
||||
def is_valid(self, offset, length = 1):
|
||||
"""Returns whether the offset is valid or not"""
|
||||
if length <= 0:
|
||||
raise TypeError("Length must be positive")
|
||||
return (self.minimum_address <= offset <= self.maximum_address and
|
||||
self.minimum_address <= offset + length - 1 <= self.maximum_address)
|
||||
|
||||
@@ -87,8 +89,6 @@ class FileLayer(interfaces.layers.DataLayerInterface):
|
||||
"""Reads from the file at offset for length"""
|
||||
if not self.is_valid(offset, length):
|
||||
raise exceptions.InvalidAddressException("Offset outside of the " + self.name + " file boundaries")
|
||||
if length < 0:
|
||||
raise TypeError("Length must be positive")
|
||||
self._file.seek(offset)
|
||||
data = self._file.read(length)
|
||||
if len(data) < length:
|
||||
|
||||
Reference in New Issue
Block a user