Skip to content

Commit

Permalink
Objects: Fix incorrect Bitfield maths
Browse files Browse the repository at this point in the history
Turns out that #133 exposed a mistake in how we were using the end_bit
field (and it should have been picked up in review, my bad).
Essentially we were masking based on the length of the end_bit after
*already* shifting by the start_bit.  We should mask then shift, not the
other way around.

May well fix issue #135 (pdb generation will have been affected by
this).
  • Loading branch information
ikelos committed Nov 13, 2019
1 parent d0a5d4b commit 648cded
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion volatility/framework/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ def __new__(cls,
end_bit: int = 0,
**kwargs) -> 'BitField':
value = base_type(context = context, object_info = object_info)
return int.__new__(cls, (value >> start_bit) & ((1 << end_bit) - 1)) # type: ignore
return int.__new__(cls, ((value & ((1 << end_bit) - 1)) >> start_bit)) # type: ignore

def write(self, value):
raise NotImplementedError("Writing to BitFields is not yet implemented")
Expand Down

0 comments on commit 648cded

Please sign in to comment.