diff --git a/volatility/framework/layers/physical.py b/volatility/framework/layers/physical.py index 64709c436..2cb600f14 100644 --- a/volatility/framework/layers/physical.py +++ b/volatility/framework/layers/physical.py @@ -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: