From e4e563ead048dda97c5cb7e4c1973d8781553616 Mon Sep 17 00:00:00 2001 From: Mike Auty Date: Sat, 3 Dec 2016 00:23:00 +0000 Subject: [PATCH] Fix up the array slicing code. --- volatility/framework/objects/__init__.py | 26 ++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/volatility/framework/objects/__init__.py b/volatility/framework/objects/__init__.py index dd64b1955..b6e6c813d 100644 --- a/volatility/framework/objects/__init__.py +++ b/volatility/framework/objects/__init__.py @@ -272,12 +272,26 @@ class Array(interfaces.objects.ObjectInterface, collections.Sequence): def __getitem__(self, i): """Returns the i-th item from the array""" - if i >= self.vol.count or 0 > i: - raise IndexError - object_info = ObjectInformation(layer_name = self.vol.layer_name, - offset = self.vol.offset + (self.vol.subtype.size * i), - parent = self) - return self.vol.subtype(context = self._context, object_info = object_info) + result = [] + if isinstance(i, slice): + if i.step: + series = range(i.start, i.stop, i.step) + elif i.start: + series = range(i.start, i.stop) + else: + series = range(i.stop) + for index in series: + object_info = ObjectInformation(layer_name = self.vol.layer_name, + offset = self.vol.offset + (self.vol.subtype.size * index), + parent = self) + result += [self.vol.subtype(context = self._context, object_info = object_info)] + else: + index = i + object_info = ObjectInformation(layer_name = self.vol.layer_name, + offset = self.vol.offset + (self.vol.subtype.size * index), + parent = self) + result = self.vol.subtype(context = self._context, object_info = object_info) + return result def __len__(self): """Returns the length of the array"""