Skip to content
New issue

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

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

Already on GitHub? # to your account

fix issues with modules fetch of memory blocks in some situations #2025

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

vthib
Copy link
Contributor

@vthib vthib commented Jan 1, 2024

Some modules functions (from hash and math) can access multiple memory blocks, as long as those are contiguous. For example, when hashing between offsets 0..1000, blocks that cover this range will be fetched.

This logic however is a bit buggy on the boundary: if the fetched range ends exactly at the end of a block, the iteration keeps going instead of ending. This can result in two situations:

  • The next block is contiguous: it is then fetched.
    • if the fetch fails, the function fails (and return undefined)
    • if the fetch succeeds, we read 0 bytes from it and end the iteration, so a useless fetch was done.
  • The next block is not contiguous: the function fails (and return undefined).

This is fixed by modifying the condition to detect if there are still more bytes to fetch.

Some modules functions (from hash and math) can access multiple memory
blocks, as long as those are contiguous. For example, when hashing
between offsets 0..1000, blocks that cover this range will be fetched.

This logic however is a bit buggy on the boundary: if the fetched range
ends exactly at the end of a block, the iteration keeps going instead of
ending. This can result in two situations:

- The next block is contiguous: it is then fetched.
  - if the fetch fails, the function fails (and return undefined)
  - if the fetch succeeds, we read 0 bytes from it and
    end the iteration, so a useless fetch was done.
- The next block is not contiguous: the function fails (and return
  undefined).

This is fixed by modifying the condition to detect if there are still
more bytes to fetch.
@plusvic plusvic merged commit 53c83c8 into VirusTotal:master Jan 12, 2024
9 checks passed
@vthib vthib deleted the fix-fetch-block-end-boundary branch January 13, 2024 09:15
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants