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

Fix offset calculation bugs in ObjectFetcher #3239

Merged
merged 2 commits into from
Nov 19, 2024
Merged

Fix offset calculation bugs in ObjectFetcher #3239

merged 2 commits into from
Nov 19, 2024

Conversation

teor2345
Copy link
Contributor

There are multiple bugs in the ObjectFetcher’s piece and segment offset calculations:

  • we’re using segment piece positions (including parity pieces) in calculations with source piece counts and lengths
  • we subtract 2 for optional padding, but if the mapping is right at the end of the segment, and the padding isn’t there (or the mapping is malicious), that calculation can underflow

I think this previously worked in automated and manual tests because the mappings were all in the first source piece, and never in the last 2 bytes of the segment. I’ll follow up with a PR containing tests for those situations.

Code contributor checklist:

@teor2345 teor2345 added the bug Something isn't working label Nov 19, 2024
@teor2345 teor2345 self-assigned this Nov 19, 2024
Copy link
Member

@nazar-pc nazar-pc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would certainly prefer to rewrite it in terms of regular positions somehow, but this will work for now

@teor2345 teor2345 added this pull request to the merge queue Nov 19, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 19, 2024
@nazar-pc nazar-pc merged commit aff971e into main Nov 19, 2024
8 checks passed
@nazar-pc nazar-pc deleted the fix-obj-offset branch November 19, 2024 18:47
@teor2345
Copy link
Contributor Author

I would certainly prefer to rewrite it in terms of regular positions somehow, but this will work for now

I’ve added this to the list of cleanups in #3106

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants