Windows Handles: Work in fixes from @attrc

These changes fix bugs encountered during regression testing related to
virtual offset validation and string length checks.
This commit is contained in:
David McDonald
2024-12-30 13:52:43 -06:00
parent 3211fc1e6c
commit 5af5363c46
2 changed files with 18 additions and 1 deletions
@@ -226,6 +226,14 @@ class Handles(interfaces.plugins.PluginInterface):
masked_offset = offset & layer_object.maximum_address
for entry in table:
# This triggered a backtrace in many testing samples
# in the level == 0 path
# The code above this calls `is_valid` on the `offset`
# It is sent but then does not validate `entry` before
# sending it to `_get_item`
if not self.context.layers[virtual].is_valid(entry.vol.offset):
continue
if level > 0:
yield from self._make_handle_array(entry, level - 1, depth)
depth += 1
@@ -376,7 +376,16 @@ class OBJECT_HEADER(objects.StructType):
try:
# vista and earlier have a Type member
self._vol["object_header_object_type"] = self.Type.Name.String
length = self.Type.member("Name").Length
if length == 0 or length > 128:
string = None
else:
string = self.Type.Name.String
if len(string) == 0 or len(string) > 128:
string = None
self._vol["object_header_object_type"] = string
except AttributeError:
# windows 7 and later have a TypeIndex, but windows 10
# further encodes the index value with nt1!ObHeaderCookie