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

panicked at 'attempt to subtract with overflow' #283

Closed
charlesxsh opened this issue Oct 2, 2021 · 1 comment · Fixed by #286
Closed

panicked at 'attempt to subtract with overflow' #283

charlesxsh opened this issue Oct 2, 2021 · 1 comment · Fixed by #286

Comments

@charlesxsh
Copy link

for a given input:
in.zip

with following code:

fn main(){
    let filepath = "<input file>";
    let data = std::fs::read(filepath).unwrap();
    let _ = goblin::Object::parse(&data);   
}

output:

thread 'main' panicked at 'attempt to subtract with overflow', /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/pe/utils.rs:35:25
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: goblin::pe::utils::section_read_size
             at /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/pe/utils.rs:35:25
   4: goblin::pe::utils::is_in_section
             at /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/pe/utils.rs:58:23
   5: goblin::pe::utils::find_offset
             at /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/pe/utils.rs:77:16
   6: goblin::pe::debug::ImageDebugDirectory::parse_with_opts
             at /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/pe/debug.rs:103:22
   7: goblin::pe::debug::DebugData::parse_with_opts
             at /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/pe/debug.rs:39:13
   8: goblin::pe::PE::parse_with_opts
             at /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/pe/mod.rs:156:35
   9: goblin::pe::PE::parse
             at /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/pe/mod.rs:66:9
  10: goblin::Object::parse
             at /home/szx5097/.cargo/registry/src/github.com-1ecc6299db9ec823/goblin-0.4.3/src/lib.rs:316:47
...

expect: properly return error instead of panic

@m4b
Copy link
Owner

m4b commented Oct 17, 2021

@charlesxsh I believe @skdltmxn 's PR fixes your issue now; could you test it out? I will probably wait a bit to roll up other changes for a minor release, unless this is urgent for some reason.

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