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

fixing by adding max index computation in bitfield validation #1344

Merged
merged 7 commits into from
Jan 18, 2022

Conversation

laudiacay
Copy link
Contributor

Summary of changes
Changes introduced in this pull request:

  • fixes issue b4 from audit

Reference issue to close (if applicable)

no relevant issue

Other information and links

See audit slack channel. ready to review, but please please look over this closely! bitfields are easy places to mess up...

Copy link
Contributor

@elmattic elmattic left a comment

Choose a reason for hiding this comment

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

You could also add the offensive payload from Alex in a test:

    #[test]
    fn iter_last() {
        // Create RLE with 2**64-2 set bits:
        let rle: Vec<u8> = vec![0xE4, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x2F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F];
        let (_bf, max) = BitField::from_bytes_with_max(&rle).unwrap();
        assert_eq!(max, 18446744073709551614);
    }

utils/bitfield/src/rleplus/mod.rs Outdated Show resolved Hide resolved
utils/bitfield/src/unvalidated.rs Outdated Show resolved Hide resolved
@laudiacay
Copy link
Contributor Author

idk how to close ur requested changes but... addressed!


#[allow(clippy::absurd_extreme_comparisons)]
if last_sector_number > MAX_SECTOR_NUMBER {
if (last_sector_number as u64) > MAX_SECTOR_NUMBER {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can have kept the type alias SectorNumber here. But otherwise lgtm.

@laudiacay laudiacay force-pushed the fix-b4-bitfield branch 2 times, most recently from 80d8cc3 to 0a64a7f Compare January 13, 2022 20:06
@noot
Copy link
Contributor

noot commented Jan 14, 2022

@laudiacay could you merge main into this when you get a chance? the clippy issues were fixed on main

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

3 participants