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 arithmetic debug assertions in elf #260

Merged
merged 2 commits into from Feb 15, 2021
Merged

Fix arithmetic debug assertions in elf #260

merged 2 commits into from Feb 15, 2021

Conversation

Mrmaxmeier
Copy link
Contributor

This adds a new fuzzing harness that covers most of the ELF module and fixes a few overflow assertions.

saturating_adds should be fine since all of the edge cases concern sizes that are bounds-checked later.

(Xref #110)

Copy link
Owner

@m4b m4b left a comment

Choose a reason for hiding this comment

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

Thanks for adding another fuzz target, this is great!

@@ -406,9 +406,9 @@ if_sylvan! {
fn hash_len(bytes: &[u8], offset: usize, machine: u16, ctx: Ctx) -> error::Result<usize> {
// Based on readelf code.
let nchain = if (machine == header::EM_FAKE_ALPHA || machine == header::EM_S390) && ctx.container.is_big() {
bytes.pread_with::<u64>(offset + 4, ctx.le)? as usize
bytes.pread_with::<u64>(offset.saturating_add(4), ctx.le)? as usize
Copy link
Owner

Choose a reason for hiding this comment

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

i think there was a concern about this before about what this would mean if it overflows, but i suppose saturating add is best here

@m4b m4b merged commit 48f6ad9 into m4b:master Feb 15, 2021
@Mrmaxmeier Mrmaxmeier deleted the fix-arith-debug-assertions branch February 23, 2021 20:49
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