Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions olefile/olefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,10 @@ def sect2array(self, sect):
swapping bytes on big endian CPUs such as PowerPC (old Macs)
"""
# TODO: make this a static function
if len(sect) % array.array(UINT32).itemsize != 0:
# to convert to an array of UINT32s we need to have a bytes string
# with a length that is a multiple of the itemsize.
self._raise_defect(DEFECT_FATAL, 'incorrect sector size, cannot convert to array of 32bit unsigned integers')
a = array.array(UINT32, sect)
# if CPU is big endian, swap bytes:
if sys.byteorder == 'big':
Expand Down