Merge pull request #1669 from volatilityfoundation/fix_node_access

Prevent backtraces when the node head is smeared
This commit is contained in:
ikelos
2025-03-05 23:41:17 +00:00
committed by GitHub
@@ -669,7 +669,7 @@ class IDStorage(ABC):
raise NotImplementedError
@abstractmethod
def get_head_node(self, tree) -> int:
def get_head_node(self, tree) -> Optional[int]:
"""Returns a pointer to the tree's head"""
raise NotImplementedError
@@ -767,8 +767,11 @@ class XArray(IDStorage):
node = self.nodep_to_node(nodep)
return (node.shift // self.CHUNK_SHIFT) + 1
def get_head_node(self, tree) -> int:
return tree.xa_head
def get_head_node(self, tree) -> Optional[int]:
try:
return tree.xa_head
except exceptions.InvalidAddressException:
return None
def node_is_internal(self, nodep) -> bool:
return (nodep & self.XARRAY_TAG_MASK) == self.XARRAY_TAG_INTERNAL
@@ -876,8 +879,11 @@ class RadixTree(IDStorage):
return height
def get_head_node(self, tree) -> int:
return tree.rnode
def get_head_node(self, tree) -> Optional[int]:
try:
return tree.rnode
except exceptions.InvalidAddressException:
return None
def node_is_internal(self, nodep) -> bool:
return (nodep & self.RADIX_TREE_INTERNAL_NODE) != 0