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

MultiArch parsing non fat binary panicked with Scroll(BadOffset()) #250

Closed
messense opened this issue Jan 20, 2021 · 2 comments · Fixed by #251
Closed

MultiArch parsing non fat binary panicked with Scroll(BadOffset()) #250

messense opened this issue Jan 20, 2021 · 2 comments · Fixed by #251

Comments

@messense
Copy link
Contributor

messense commented Jan 20, 2021

Ideally it should return an Err instead of panicking?

[dependencies]
goblin = "0.3.1"
use goblin::mach::MultiArch;

fn main() {
    let fat = MultiArch::new(include_bytes!("thin_x86_64")).unwrap();   //  this returns Ok
    println!("{:?}", fat);  // panicked here
}

thin_x86_64 file thin_x86_64.zip

$ cargo run
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Scroll(BadOffset(8))', goblin-0.3.1/src/mach/mod.rs:413:45
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
MultiArch

.field("arches", &self.arches().unwrap())

@messense messense changed the title MultiArch parsing non fat binary paniced with Scroll(BadOffset()) MultiArch parsing non fat binary panicked with Scroll(BadOffset()) Jan 20, 2021
@messense
Copy link
Contributor Author

OK, I think I should use Mach::parse instead of MultiArch::parse.

@m4b
Copy link
Owner

m4b commented Jan 20, 2021

Ok but this is still really undesirable behavior panicking in the debug printer. Would be nice to change that unwrap to an unwra_or(“NO_ARCHES”) or something

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 a pull request may close this issue.

2 participants