Skip to content

jiff::fmt::strtime::parse panics on certain malformed inputs due to integer overflow #426

@apasel422

Description

@apasel422

Example code:

 _ = jiff::fmt::strtime::parse([37, 94, 53, 48, 67, 37], [50, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 35, 48, 48, 55, 55, 41, 40, 41]);

Output:

panicked at src/fmt/strtime/parse.rs:869:45:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: __rustc::rust_begin_unwind
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/std/src/panicking.rs:697:5
   1: core::panicking::panic_fmt
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:75:14
   2: core::panicking::panic
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/panicking.rs:145:5
   3: core::option::unwrap_failed
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/option.rs:2130:5
   4: core::option::Option<T>::unwrap
             at /rustc/1159e78c4747b02ef996e55082b704c09b970588/library/core/src/option.rs:1009:21
   5: jiff::fmt::strtime::parse::Parser::parse_century
             at ./src/fmt/strtime/parse.rs:869:45
   6: jiff::fmt::strtime::parse::Parser::parse
             at ./src/fmt/strtime/parse.rs:56:30
   7: jiff::fmt::strtime::BrokenDownTime::parse_mono
             at ./src/fmt/strtime/mod.rs:941:11
   8: jiff::fmt::strtime::BrokenDownTime::parse
             at ./src/fmt/strtime/mod.rs:934:9
   9: jiff::fmt::strtime::parse
             at ./src/fmt/strtime/mod.rs:355:5

century=2000000000000000000 prior to the checked multiplication by 100.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions