Skip to content

Commit

Permalink
Improve exception when reading out of bounds EWF segment (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSCU-CNI committed Feb 19, 2024
1 parent 950dbaf commit 464f32c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions dissect/evidence/ewf.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,11 @@ def _read(self, offset: int, length: int) -> bytes:
sector_count = (length + self.sector_size - 1) // self.sector_size

segment_idx = bisect_right(self.ewf._segment_offsets, sector_offset)

while sector_count > 0:
if segment_idx > len(self.ewf._segment_offsets):
raise EWFError(f"Missing EWF file for segment index: {segment_idx}")

segment = self.ewf.open_segment(segment_idx)

segment_remaining_sectors = segment.sector_count - (sector_offset - segment.sector_offset)
Expand Down

0 comments on commit 464f32c

Please sign in to comment.