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

Panic when parsing malformed signature #146

Open
5225225 opened this issue Nov 16, 2021 · 0 comments
Open

Panic when parsing malformed signature #146

5225225 opened this issue Nov 16, 2021 · 0 comments
Labels

Comments

@5225225
Copy link

5225225 commented Nov 16, 2021

Reproduction code:

use pgp::de::Deserialize;

fn main() {
    let data = [5, 2, 2, 11, 0, 2, 0, 0];
    let _ = pgp::Signature::from_slice(pgp::types::Version::New, &data);
}

Error:

thread 'main' panicked at 'attempt to subtract with overflow', /home/jess/.cargo/registry/src/github.com-1ecc6299db9ec823/pgp-0.7.2/src/packet/signature/de.rs:316:29
stack backtrace:
   0: rust_begin_unwind
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/core/src/panicking.rs:106:14
   2: core::panicking::panic
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/core/src/panicking.rs:47:5
   3: pgp::packet::signature::de::subpackets
             at /home/jess/.cargo/registry/src/github.com-1ecc6299db9ec823/pgp-0.7.2/src/packet/signature/de.rs:316:29
   4: pgp::packet::signature::de::v4_parser::{{closure}}
             at /home/jess/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-4.2.3/src/simple_errors.rs:195:15
   5: core::result::Result<T,E>::and_then
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/core/src/result.rs:966:22
   6: pgp::packet::signature::de::v4_parser
             at /home/jess/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-4.2.3/src/macros.rs:239:13
   7: pgp::packet::signature::de::parse
             at /home/jess/.cargo/registry/src/github.com-1ecc6299db9ec823/nom-4.2.3/src/macros.rs:239:13
   8: pgp::packet::signature::de::<impl pgp::de::Deserialize for pgp::packet::signature::types::Signature>::from_slice
             at /home/jess/.cargo/registry/src/github.com-1ecc6299db9ec823/pgp-0.7.2/src/packet/signature/de.rs:25:23
   9: scratchbZarvjayp::main
             at ./src/main.rs:5:13
  10: core::ops::function::FnOnce::call_once
             at /rustc/891ca5f63c3b3cfe3939710a728671243e881ed6/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants