Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise an exception when sector cannot be converted to array #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ret2libc
Copy link

This can happen for example if _raise_defects_level is DETECT_FATAL and sector_size is computed to be 1 (sector_shift==0).

This can happen for example if _raise_defects_level is DETECT_FATAL and
sector_size is computed to be 1 (sector_shift==0).
@decalage2 decalage2 self-requested a review October 28, 2022 21:03
@decalage2 decalage2 self-assigned this Oct 28, 2022
@decalage2
Copy link
Owner

Thank you for the suggestion. Two questions:

  • do you have any functioning sample with a sector size different from the standard 512 or 4096 bytes? Personally I have never seen any. So when parsing the header, other values could raise a DEFECT_FATAL error instead of DEFECT_INCORRECT.
  • if we accept non-standard sector sizes, wouldn't it be simpler to check that sector_shift is at least 2 when parsing the header? (since the function is parsing an array of 32 bit integers, the minimum sector size should be 4)

@decalage2 decalage2 added this to the olefile 0.47 milestone Oct 28, 2022
@ret2libc
Copy link
Author

ret2libc commented Nov 3, 2022

Thank you for the suggestion. Two questions:

  • do you have any functioning sample with a sector size different from the standard 512 or 4096 bytes? Personally I have never seen any. So when parsing the header, other values could raise a DEFECT_FATAL error instead of DEFECT_INCORRECT.

Not functioning, but fuzzed files that reach the sect2array function and generate an exception there exists.

  • if we accept non-standard sector sizes, wouldn't it be simpler to check that sector_shift is at least 2 when parsing the header? (since the function is parsing an array of 32 bit integers, the minimum sector size should be 4)

I agree, I can do the change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants