From d0ff961ed1969ce5b8ecd5ad89dda8e7d782098f Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Thu, 9 May 2019 00:06:07 +0100 Subject: [PATCH] Revert "Trade off memory for disk reads." This reverts commit 20c609b1806ec4a595ee5e3b9f12481e2d01d97d. --- volatility/framework/layers/physical.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/volatility/framework/layers/physical.py b/volatility/framework/layers/physical.py index d17feb3f0..4c6efb0eb 100644 --- a/volatility/framework/layers/physical.py +++ b/volatility/framework/layers/physical.py @@ -17,7 +17,6 @@ # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the # specific language governing rights and limitations under the License. # -import functools import threading from typing import Any, Dict, IO, List, Optional, Union @@ -156,22 +155,18 @@ class FileLayer(interfaces.layers.DataLayerInterface): invalid_address = self.maximum_address + 1 raise exceptions.InvalidAddressException(self.name, invalid_address, "Offset outside of the buffer boundaries") - return self._read(self._file, self._lock, self.name, offset, length, pad) - @staticmethod - @functools.lru_cache(4096) - def _read(file_object: IO[Any], lock, name: str, offset: int, length: int, pad: bool = False) -> bytes: # TODO: implement locking for multi-threading - with lock: - file_object.seek(offset) - data = file_object.read(length) + with self._lock: + self._file.seek(offset) + data = self._file.read(length) if len(data) < length: if pad: data += (b"\x00" * (length - len(data))) else: - raise exceptions.InvalidAddressException(name, offset + len(data), - "Could not read sufficient bytes from the " + name + " file") + raise exceptions.InvalidAddressException( + self.name, offset + len(data), "Could not read sufficient bytes from the " + self.name + " file") return data def write(self, offset: int, data: bytes) -> None: